[PATCH v2] drivers: scsi: fix double decrement of block count in 64-bit LBA path

Tony Dinh mibodhi at gmail.com
Mon Dec 22 23:09:20 CET 2025


On Mon, Dec 22, 2025 at 1:01 AM Balaji Selvanathan
<balaji.selvanathan at oss.qualcomm.com> wrote:
>
> The scsi_read function incorrectly decrements the block count twice
> when handling large disks that trigger the CONFIG_SYS_64BIT_LBA code
> path (reads beyond block 268,435,455). The variable 'blks' was being
> decremented both inside the 64-bit LBA block and after the successful
> scsi_exec() call, causing incorrect block count tracking and data
> abort errors on large capacity disks.
>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>

Tested-by: Tony Dinh <mibodhi at gmail.com>

All the best,
Tony

> ---
> v2:
> - No changes from v1; just a resend
> - Link to v1: https://lore.kernel.org/u-boot/20251222042533.2024310-1-balaji.selvanathan@oss.qualcomm.com/
> ---
>  drivers/scsi/scsi.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index b414d022f3f..8fe6b38a8c7 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -220,7 +220,6 @@ static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>                         pccb->datalen = block_dev->blksz * blocks;
>                         scsi_setup_read16(pccb, start, blocks);
>                         start += blocks;
> -                       blks -= blocks;
>                 } else
>  #endif
>                 if (blks > max_blks) {
> --
> 2.34.1
>


More information about the U-Boot mailing list