scsi: sd: Fix sd_done() sense handling condition

Only enter the sense_key switch when the command returned CHECK
CONDITION with valid, non-deferred sense. The old condition let deferred
or invalid sense fall through and mis-handle the I/O.

Fixes: 03aba2f795 ("[SCSI] sd/scsi_lib simplify sd_rw_intr and scsi_io_completion")
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260707030333.22245-4-yangxiuwei@kylinos.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
Yang Xiuwei
2026-07-07 11:03:33 +08:00
committed by Martin K. Petersen (Oracle)
parent bb31844d88
commit a640d4546b

View File

@@ -2419,8 +2419,8 @@ static int sd_done(struct scsi_cmnd *SCpnt)
}
sdkp->medium_access_timed_out = 0;
if (!scsi_status_is_check_condition(result) &&
(!sense_valid || sense_deferred))
if (!scsi_status_is_check_condition(result) ||
!sense_valid || sense_deferred)
goto out;
switch (sshdr.sense_key) {