drivers: scsi: fix inaccurate block count reporting in scsi operations
authorBalaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Mon, 28 Jul 2025 16:21:05 +0000 (21:51 +0530)
committerTom Rini <trini@konsulko.com>
Thu, 7 Aug 2025 17:14:23 +0000 (11:14 -0600)
commitb32dda34506b4f486bc803d0c7251f987edd2455
treedbe7c1f03c168f16c8bf01987b90a75db43404c0
parente652183ca06d3795052df389992533fd539d8dee
drivers: scsi: fix inaccurate block count reporting in scsi operations

The 'blks' variable in scsi_read/write/erase functions is updated
regardless of pass/fail of the scsi operation . If the scsi operation
fails, 'blkcnt' is updated using an incorrect value of 'blks'. This
wrong 'blkcnt' is returned to the caller and it assumes all blocks were
processed correctly.

Fix this by updating the 'blks' variable only if the scsi operation
succeeds.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/scsi/scsi.c