* [PATCH v3] usb-storage: Check whether divisors are non-zero
@ 2024-05-23 12:42 Shichao Lai
0 siblings, 0 replies; only message in thread
From: Shichao Lai @ 2024-05-23 12:42 UTC (permalink / raw)
To: stern, gregkh, oneukum
Cc: linux-usb, usb-storage, linux-kernel, Shichao Lai, xingwei lee, yue sun
Since uzonesize may be zero, so checks for non-zero
are necessary in two places of alauda.c.
Reported-by: xingwei lee <xrivendell7@gmail.com>
Reported-by: yue sun <samsun1006219@gmail.com>
Signed-off-by: Shichao Lai <shichaorai@gmail.com>
---
Changes since v1:
- Add one more check in alauda_write_lba().
- Move check ahead of loop in alauda_read_data().
- Change the order of variable list in alauda_write_lba().
drivers/usb/storage/alauda.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 115f05a6201a..ebef1a8a7ca4 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -816,8 +816,10 @@ static int alauda_write_lba(struct us_data *us, u16 lba,
unsigned int zonesize = MEDIA_INFO(us).zonesize;
unsigned int pagesize = MEDIA_INFO(us).pagesize;
unsigned int blocksize = MEDIA_INFO(us).blocksize;
- unsigned int lba_offset = lba % uzonesize;
unsigned int new_pba_offset;
+ if (!uzonesize)
+ return USB_STOR_TRANSPORT_ERROR;
+ unsigned int lba_offset = lba % uzonesize;
unsigned int zone = lba / uzonesize;
alauda_ensure_map_for_zone(us, zone);
@@ -923,6 +925,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
struct scatterlist *sg;
int result;
+ if (!uzonesize)
+ return USB_STOR_TRANSPORT_ERROR;
/*
* Since we only read in one block at a time, we have to create
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-23 12:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-23 12:42 [PATCH v3] usb-storage: Check whether divisors are non-zero Shichao Lai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®