]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: sg: Report request-table problems when any status is set
authorXu Rao <raoxu@uniontech.com>
Tue, 7 Jul 2026 03:08:45 +0000 (11:08 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 9 Jul 2026 01:59:45 +0000 (21:59 -0400)
SG_GET_REQUEST_TABLE reports per-request diagnostic state through
sg_req_info::problem. The field is meant to indicate whether there is an
error to report for a completed request.

sg_fill_request_table() currently combines masked_status, host_status
and driver_status with bitwise AND. This only reports a problem when all
three status fields are non-zero at the same time. A normal target check
condition, for example, has masked_status set while host_status and
driver_status may both be zero, so the request is incorrectly reported
as clean.

Use the same condition as sg_new_read(), which sets SG_INFO_CHECK when
any of the three status fields is non-zero.

Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/54B60C19F7DB8889+20260707030845.970018-1-raoxu@uniontech.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sg.c

index 74cd4e8a61c2a089332825ca7684d74d46e6cfcc..5408f002e6c01f1f62f824dddf8e855be5306261 100644 (file)
@@ -863,10 +863,9 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
                if (val >= SG_MAX_QUEUE)
                        break;
                rinfo[val].req_state = srp->done + 1;
-               rinfo[val].problem =
-                       srp->header.masked_status &
-                       srp->header.host_status &
-                       srp->header.driver_status;
+               rinfo[val].problem = srp->header.masked_status ||
+                                            srp->header.host_status ||
+                                            srp->header.driver_status;
                if (srp->done)
                        rinfo[val].duration =
                                srp->header.duration;