Check whether divisor is non-zero before division
Subsystems (2)
PATCH 1/1 Check whether divisor is non-zero before division
Since uzonesize may be zero, so a judgement for non-zero is nessesary.
--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/storage/alauda.c +2 -0
@@ -947,6 +947,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, sg =NULL ;while (sectors >0 ) { +if (!uzonesize) +return USB_STOR_TRANSPORT_ERROR ;unsigned int zone = lba / uzonesize;/* integer division */ unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;
Signature · 1 line
2.34.1
Greg KH
maintainerQuoted 26 lines · Shichao Lai
Since uzonesize may be zero, so a judgement for non-zero is nessesary.
Reported-by xingwei lee <[email protected]>Reported-by yue sun <[email protected]>Signed-off-by Shichao Lai <[email protected]>--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/storage/alauda.c +2
-0@@ -947,6 +947,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, sg =NULL ;while (sectors >0 ) { +if (!uzonesize) +return USB_STOR_TRANSPORT_ERROR ;unsigned int zone = lba / uzonesize;/* integer division */ unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;Signature · 1 line
2.34.1
Looks good, thanks! I'll queue this up after 6.10-rc1 is out.
greg k-h
On 23.05.24 09:22, Shichao Lai wrote:
Hi,
Quoted 14 lines
Since uzonesize may be zero, so a judgement for non-zero is nessesary.
Reported-by xingwei lee <[email protected]>Reported-by yue sun <[email protected]>Signed-off-by Shichao Lai <[email protected]>--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/storage/alauda.c +0
-0
drivers/usb/storage/alauda.c static int alauda_read_data(struct us_data *us, unsigned long address, · line 951
Quoted 5 lines
drivers/usb/storage/alauda.c +2
-0@@ -947,6 +947,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, sg =NULL ;while (sectors >0 ) { +if (!uzonesize) +return USB_STOR_TRANSPORT_ERROR ;
May I point out that uzonesize does not change in this function? There is no need to retest within the loop.
drivers/usb/storage/alauda.c static int alauda_read_data(struct us_data *us, unsigned long address, · line 954
Quoted 3 lines
drivers/usb/storage/alauda.c +0
-0unsigned int zone = lba / uzonesize;/* integer division */ unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;
Secondly, alauda_write_lba() has the same issue.
You also need to check in alauda_write_data().
Regards
Oliver
Quoted 32 lines · Oliver Neukum
On 23.05.24 09:22, Shichao Lai wrote:
Hi,
Quoted 14 lines
Since uzonesize may be zero, so a judgement for non-zero is nessesary.
Reported-by xingwei lee <[email protected]>Reported-by yue sun <[email protected]>Signed-off-by Shichao Lai <[email protected]>--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)drivers/usb/storage/alauda.c +0
-0drivers/usb/storage/alauda.c static int alauda_read_data(struct us_data *us, unsigned long address, · line 951
Quoted 5 lines
drivers/usb/storage/alauda.c +2
-0@@ -947,6 +947,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, sg =NULL ;while (sectors >0 ) { +if (!uzonesize) +return USB_STOR_TRANSPORT_ERROR ;May I point out that uzonesize does not change in this function? There is no need to retest within the loop.
drivers/usb/storage/alauda.c static int alauda_read_data(struct us_data *us, unsigned long address, · line 954
Quoted 3 lines
drivers/usb/storage/alauda.c +0
-0unsigned int zone = lba / uzonesize;/* integer division */ unsigned int lba_offset = lba - (zone * uzonesize);unsigned int pages;
Quoted 5 lines
Secondly,
alauda_write_lba()has the same issue.
You also need to check inalauda_write_data().Regards
Oliver
Thanks for the helpful tip!
I reviewed the code. Your suggestions can actually avoid repeated checks. And there is also such a problem in alauda_write_lba().
I am a beginner at making patches. May I commit a patch again which fixes both issues you mentioned?
Quoted 5 lines · shichao lai
Thanks for the helpful tip!
I reviewed the code. Your suggestions can actually avoid repeated checks. And there is also such a problem inalauda_write_lba().
I am a beginner at making patches. May I commit a patch again which fixes both issues you mentioned?
Hi,
yes, you usually are supposed to change the "[PATCH]" in the subject line to "[PATCHv2]" and add a line in the log describing the difference between the first and second version.
HTH
Oliver