public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk SCSI_IOCTL_SEND_COMMAND
@ 2003-04-29 12:01 Douglas Gilbert
  0 siblings, 0 replies; only message in thread
From: Douglas Gilbert @ 2003-04-29 12:01 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi, axboe

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

While playing with RH9.0 and 2.5.68 I found that
scsi_unique_id (called from devlabel) oopsed on
a regular basis during bootup.

This patch addresses flakiness in sense buffer
handling (in the failure case a disk didn't support
VPD page 0x83).

Note that this patch modifies drivers/block/scsi_ioctl.c

Doug Gilbert

[-- Attachment #2: scsi_ioctl_blk2568.diff --]
[-- Type: text/plain, Size: 1197 bytes --]

--- linux/drivers/block/scsi_ioctl.c	2003-04-08 10:50:03.000000000 +1000
+++ linux/drivers/block/scsi_ioctl.c2568dpg	2003-04-29 21:41:31.082437736 +1000
@@ -324,13 +324,14 @@
 #define MOVE_MEDIUM_TIMEOUT		(5 * 60 * HZ)
 #define READ_ELEMENT_STATUS_TIMEOUT	(5 * 60 * HZ)
 #define READ_DEFECT_DATA_TIMEOUT	(60 * HZ )
+#define OMAX_SB_LEN 16          /* For backward compatibility */
 
 static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
 			 Scsi_Ioctl_Command *sic)
 {
 	struct request *rq;
 	int err, in_len, out_len, bytes, opcode, cmdlen;
-	char *buffer = NULL, sense[24];
+	char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
 
 	/*
 	 * get in an out lengths, verify they don't exceed a page worth of data
@@ -403,9 +404,12 @@
 	blk_do_rq(q, bdev, rq);
 	err = rq->errors & 0xff;	/* only 8 bit SCSI status */
 	if (err) {
-		if (rq->sense_len)
-			if (copy_to_user(sic->data, rq->sense, rq->sense_len))
+		if (rq->sense_len && rq->sense) {
+			bytes = (OMAX_SB_LEN > rq->sense_len) ?
+				rq->sense_len : OMAX_SB_LEN;
+			if (copy_to_user(sic->data, rq->sense, bytes))
 				err = -EFAULT;
+		}
 	} else {
 		if (copy_to_user(sic->data, buffer, out_len))
 			err = -EFAULT;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-04-29 11:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-29 12:01 [PATCH] blk SCSI_IOCTL_SEND_COMMAND Douglas Gilbert

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