diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2021-08-20 09:02:55 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-09-29 06:10:57 +0200 |
commit | c749301ebee82eb5e97dec14b6ab31a4aabe37a6 (patch) | |
tree | 829c93e2747997981d0cdda0421bad1e1c5b53d2 /drivers/scsi/sd.c | |
parent | scsi: core: Fix scsi_mode_select() buffer length handling (diff) | |
download | linux-c749301ebee82eb5e97dec14b6ab31a4aabe37a6.tar.xz linux-c749301ebee82eb5e97dec14b6ab31a4aabe37a6.zip |
scsi: sd: Fix sd_do_mode_sense() buffer length handling
For devices that explicitly asked for MODE SENSE(10) use, make sure that
scsi_mode_sense() is called with a buffer of at least 8 bytes so that the
sense header fits.
Link: https://lore.kernel.org/r/20210820070255.682775-4-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index cbd9999f93a6..71fa70b42c2b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2604,6 +2604,13 @@ sd_do_mode_sense(struct scsi_disk *sdkp, int dbd, int modepage, unsigned char *buffer, int len, struct scsi_mode_data *data, struct scsi_sense_hdr *sshdr) { + /* + * If we must use MODE SENSE(10), make sure that the buffer length + * is at least 8 bytes so that the mode sense header fits. + */ + if (sdkp->device->use_10_for_ms && len < 8) + len = 8; + return scsi_mode_sense(sdkp->device, dbd, modepage, buffer, len, SD_TIMEOUT, sdkp->max_retries, data, sshdr); |