public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: storage: sddr55: avoid integer overflow
@ 2023-02-03 20:18 Karina Yankevich
  2023-02-03 20:48 ` Alan Stern
  0 siblings, 1 reply; 8+ messages in thread
From: Karina Yankevich @ 2023-02-03 20:18 UTC (permalink / raw)
  To: Alan Stern
  Cc: Karina Yankevich, Greg Kroah-Hartman, linux-usb, usb-storage,
	linux-kernel, lvc-project

We're possibly losing information by shifting an int.
Fix it by adding the necessary cast.

Found by OMP on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
---
 drivers/usb/storage/sddr55.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index 15dc25801cdc..4aeff73de147 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -236,7 +236,7 @@ static int sddr55_read_data(struct us_data *us,
 			memset (buffer, 0, len);
 		} else {
 
-			address = (pba << info->blockshift) + page;
+			address = ((unsigned long)pba << info->blockshift) + page;
 
 			command[0] = 0;
 			command[1] = LSB_of(address>>16);
@@ -411,7 +411,7 @@ static int sddr55_write_data(struct us_data *us,
 			command[4] = 0x40;
 		}
 
-		address = (pba << info->blockshift) + page;
+		address = ((unsigned long)pba << info->blockshift) + page;
 
 		command[1] = LSB_of(address>>16);
 		command[2] = LSB_of(address>>8); 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-01 22:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 20:18 [PATCH] usb: storage: sddr55: avoid integer overflow Karina Yankevich
2023-02-03 20:48 ` Alan Stern
2023-02-06 20:04   ` Sergei Shtylyov
2023-02-06 20:17     ` Alan Stern
2023-02-27 11:25     ` [PATCH v2] usb: storage: sddr55: clean up variable type Karina Yankevich
2023-02-27 11:54       ` Greg Kroah-Hartman
2023-12-01 16:16         ` Sergei Shtylyov
2023-12-01 22:36           ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox