public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: dougg@torque.net
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] scsi_debug: illegal blocking memory allocation
Date: Wed, 3 Jan 2007 14:49:07 +0100	[thread overview]
Message-ID: <20070103134907.GV11203@kernel.dk> (raw)

Hi Doug,

resp_inquiry() does a GFP_KERNEL memory allocation, but it's not allowed
to from the queuecommand context. There's no good way to return this
error, so I used DID_ERROR which is used from similar paths. That
doesn't seem quite right though, it would be better to return an error
indicating a later retry would be more appropriate.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 30ee3d7..0c80ed3 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -954,7 +954,9 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
 	int alloc_len, n, ret;
 
 	alloc_len = (cmd[3] << 8) + cmd[4];
-	arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_KERNEL);
+	arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_ATOMIC);
+	if (!arr)
+		return DID_ERROR << 16;
 	if (devip->wlun)
 		pq_pdt = 0x1e;	/* present, wlun */
 	else if (scsi_debug_no_lun_0 && (0 == devip->lun))

-- 
Jens Axboe


             reply	other threads:[~2007-01-03 13:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-03 13:49 Jens Axboe [this message]
2007-01-04  5:38 ` [PATCH] scsi_debug: illegal blocking memory allocation Douglas Gilbert
2007-01-04 11:21   ` Jens Axboe
2007-01-04 15:10     ` James Bottomley
2007-01-04 15:27       ` Matthew Wilcox
2007-01-04 15:34         ` James Bottomley
2007-01-04 15:50       ` Jens Axboe
2007-01-05  5:30         ` Douglas Gilbert
2007-01-05 12:49           ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070103134907.GV11203@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=dougg@torque.net \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox