public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_debug: illegal blocking memory allocation
@ 2007-01-03 13:49 Jens Axboe
  2007-01-04  5:38 ` Douglas Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Jens Axboe @ 2007-01-03 13:49 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-01-05 12:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-03 13:49 [PATCH] scsi_debug: illegal blocking memory allocation Jens Axboe
2007-01-04  5:38 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox