Like sd_pr_command, before use sshdr, we need to check the result of scsi_execute. Signed-off-by: zhengbin <zhengbin13@xxxxxxxxxx> --- drivers/scsi/sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 4664fdf..5c5476b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -205,7 +205,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, sizeof(buf), &sshdr, SR_TIMEOUT, MAX_RETRIES, NULL); - if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION) + if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION) return DISK_EVENT_MEDIA_CHANGE; if (result || be16_to_cpu(eh->data_len) < sizeof(*med)) -- 2.7.4