Skip to content

Commit 8f00176

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: Fix sshdr use in scsi_cdl_enable
If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0. Signed-off-by: Mike Christie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: John Garry <[email protected]> Reviewed-by: Martin Wilck <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f43158e commit 8f00176

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
692692
ret = scsi_mode_select(sdev, 1, 0, buf_data, len, 5 * HZ, 3,
693693
&data, &sshdr);
694694
if (ret) {
695-
if (scsi_sense_valid(&sshdr))
695+
if (ret > 0 && scsi_sense_valid(&sshdr))
696696
scsi_print_sense_hdr(sdev,
697697
dev_name(&sdev->sdev_gendev), &sshdr);
698698
return ret;

0 commit comments

Comments
 (0)