提交 c749301e 编写于 作者: D Damien Le Moal 提交者: Martin K. Petersen

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.comSigned-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 a7d6840b
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册