Like sd_pr_command, before use sshdr, we need to check whether
sshdr is valid.

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

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) {
--
2.7.4

Reply via email to