public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dougg@torque.net>
To: James.Bottomley@steeleye.com
Cc: linux-scsi@vger.kernel.org, axboe@suse.de
Subject: [PATCH] blk SCSI_IOCTL_SEND_COMMAND
Date: Tue, 29 Apr 2003 22:01:22 +1000	[thread overview]
Message-ID: <3EAE6992.9090605@torque.net> (raw)

[-- 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;

                 reply	other threads:[~2003-04-29 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3EAE6992.9090605@torque.net \
    --to=dougg@torque.net \
    --cc=James.Bottomley@steeleye.com \
    --cc=axboe@suse.de \
    --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