diff mbox series

[v5,11/13] scsi: cxlflash: need to check whether sshdr is valid in read_cap16

Message ID 1571387071-28853-12-git-send-email-zhengbin13@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series scsi: core: fix uninit-value access of variable sshdr | expand

Commit Message

Zheng Bin Oct. 18, 2019, 8:24 a.m. UTC
Like sd_pr_command, before use sshdr, we need to check whether
sshdr is valid.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 drivers/scsi/cxlflash/superpipe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.7.4
diff mbox series

Patch

diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index 593669a..1e90ff3 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -369,7 +369,7 @@  static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
 		goto out;
 	}

-	if (driver_byte(result) == DRIVER_SENSE) {
+	if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) {
 		result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
 		if (result & SAM_STAT_CHECK_CONDITION) {
 			switch (sshdr.sense_key) {