On 2/22/22 06:04, Christoph Hellwig wrote:
@@ -613,10 +614,10 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
err = req->result & 0xff; /* only 8 bit SCSI status */
if (err) {
- if (req->sense_len && req->sense) {
- bytes = (OMAX_SB_LEN > req->sense_len) ?
- req->sense_len : OMAX_SB_LEN;
- if (copy_to_user(sic->data, req->sense, bytes))
+ if (scmd->sense_len && scmd->sense_buffer) {
+ bytes = (OMAX_SB_LEN > scmd->sense_len) ?
+ scmd->sense_len : OMAX_SB_LEN;
+ if (copy_to_user(sic->data, scmd->sense_buffer, bytes))
err = -EFAULT;
}
} else {
This change would be a good opportunity to remove the two superfluous
parentheses from the above code.
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 3e432e25645ac..47add5b32f460 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -112,6 +112,7 @@ struct scsi_cmnd {
reconnects. Probably == sector
size */
+ unsigned sense_len;
unsigned char *sense_buffer;
/* obtained by REQUEST SENSE when
* CHECK CONDITION is received on original
Isn't "unsigned int" preferred over "unsigned" in new code?
Anyway:
Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>