Commit c10995cf authored by Douglas Gilbert's avatar Douglas Gilbert Committed by James Bottomley

[PATCH] blk SCSI_IOCTL_SEND_COMMAND

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).
parent 4bfb6239
......@@ -299,13 +299,14 @@ static int sg_io(request_queue_t *q, struct block_device *bdev,
#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
......@@ -378,9 +379,12 @@ static int sg_scsi_ioctl(request_queue_t *q, struct block_device *bdev,
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment