On 2026-10-28T05:50:48, Ana Bobillo <[email protected]> wrote:
> usb: storage: Fix the capacity faked when READ CAPACITY fails
>
> When READ CAPACITY fails, usb_stor_get_info() makes up a reply of its own
> for a 1.44MB floppy, 2880 blocks of 512 bytes. But it sets the values in
> host byte order, while the reply is read back as big endian, so on a
> little-endian host the device gets 0x400b0001 blocks (about 1G) of 128KiB
> rather than 2880 of 512 bytes. It also puts 2880 where READ CAPACITY
> returns the last LBA, so even on a big-endian host the device gets 2881
> blocks.
>
> Set the reply in big endian like the one it stands in for, with 2879 as
> the last LBA, so that such a device has 2880 blocks of 512 bytes on any
> host.
>
> Fixes: 149dded2b178 ("* Add support for USB Mass Storage Devices (BBB)   
> (tested with USB memory sticks only)")
> Signed-off-by: Ana Bobillo <[email protected]>
>
>  common/usb_storage.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <[email protected]>

Reply via email to