Like sd_pr_command, before use sshdr, we need to check the result of scsi_execute. Signed-off-by: zhengbin <zhengbin13@xxxxxxxxxx> --- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 8acd4bb..be8c139 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -90,7 +90,8 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL); if (res) { - if (scsi_sense_valid(&sshdr)) + if (driver_byte(res) == DRIVER_SENSE && + scsi_sense_valid(&sshdr)) ret = tur_done(sdev, h, &sshdr); else { sdev_printk(KERN_WARNING, sdev, @@ -128,7 +129,8 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL); if (res) { - if (!scsi_sense_valid(&sshdr)) { + if (driver_byte(result) != DRIVER_SENSE || + !scsi_sense_valid(&sshdr)) { sdev_printk(KERN_WARNING, sdev, "%s: sending start_stop_unit failed, " "no sense available\n", HP_SW_NAME); -- 2.7.4