Like sd_pr_command, before use sshdr, we need to check whether sshdr is valid. Signed-off-by: zhengbin <zhengbin13@xxxxxxxxxx> --- drivers/scsi/ch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 76751d6..dba6fe2 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -200,7 +200,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, buflength, &sshdr, timeout * HZ, MAX_RETRIES, NULL); - if (driver_byte(result) == DRIVER_SENSE) { + if (driver_byte(result) == DRIVER_SENSE && scsi_sense_valid(&sshdr)) { if (debug) scsi_print_sense_hdr(ch->device, ch->name, &sshdr); errno = ch_find_errno(&sshdr); @@ -212,7 +212,9 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, goto retry; break; } - } + } else if (result) + errno = -EIO; + return errno; } -- 2.7.4