Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: storage: sddr55: fix sloppy typing in sddr55_{read|write}_data()

In sddr55_{read|write}_data(), the address variables are needlessly typed
as *unsigned long* -- which is 32-bit type on the 32-bit arches and 64-bit
type on the 64-bit arches; those variables' value should fit into just 3
command bytes and consists of 10-bit block # (or at least the max block #
seems to be 1023) and 4-/5-bit page # within a block, so 32-bit *unsigned*
*int* type should be more than enough...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

[Sergey: rewrote the patch subject/description]

Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/4c9485f2-0bfc-591b-bfe7-2059289b554e@omp.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Karina Yankevich and committed by
Greg Kroah-Hartman
d6429a35 7626c52b

+2 -2
+2 -2
drivers/usb/storage/sddr55.c
··· 196 196 unsigned char *buffer; 197 197 198 198 unsigned int pba; 199 - unsigned long address; 199 + unsigned int address; 200 200 201 201 unsigned short pages; 202 202 unsigned int len, offset; ··· 316 316 317 317 unsigned int pba; 318 318 unsigned int new_pba; 319 - unsigned long address; 319 + unsigned int address; 320 320 321 321 unsigned short pages; 322 322 int i;