[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACjpba7yh5Soe_Pr7D3SeTjjqzQB9q=nThaYRGAZu+EvaLfxfw@mail.gmail.com>
Date: Thu, 23 May 2024 17:12:36 +0800
From: shichao lai <shichaorai@...il.com>
To: Oliver Neukum <oneukum@...e.com>, stern@...land.harvard.edu, gregkh@...uxfoundation.org
Cc: linux-usb@...r.kernel.org, usb-storage@...ts.one-eyed-alien.net,
linux-kernel@...r.kernel.org, xingwei lee <xrivendell7@...il.com>,
yue sun <samsun1006219@...il.com>
Subject: Re: [PATCH] Check whether divisor is non-zero before division
On Thu, May 23, 2024 at 4:18 PM Oliver Neukum <oneukum@...e.com> wrote:
>
> On 23.05.24 09:22, Shichao Lai wrote:
>
> Hi,
>
> > Since uzonesize may be zero, so a judgement for non-zero is nessesary.
> >
> > Reported-by: xingwei lee <xrivendell7@...il.com>
> > Reported-by: yue sun <samsun1006219@...il.com>
> > Signed-off-by: Shichao Lai <shichaorai@...il.com>
> > ---
> > drivers/usb/storage/alauda.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
> > index 115f05a6201a..db075a8c03cb 100644
> > --- a/drivers/usb/storage/alauda.c
> > +++ b/drivers/usb/storage/alauda.c
> > @@ -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.
>
> > unsigned 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
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?
Powered by blists - more mailing lists