From: Greg KH <gregkh@linuxfoundation.org>
To: shichao lai <shichaorai@gmail.com>
Cc: oneukum@suse.com, stern@rowland.harvard.edu,
linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
linux-kernel@vger.kernel.org, xingwei lee <xrivendell7@gmail.com>,
yue sun <samsun1006219@gmail.com>
Subject: Re: [PATCH v2] usb-storage: Check whether divisor is non-zero before division
Date: Thu, 23 May 2024 14:37:18 +0200 [thread overview]
Message-ID: <2024052354-snorkel-drainer-d328@gregkh> (raw)
In-Reply-To: <CACjpba7k2+GS3c+NGgOeP=9=DU8Mh1DFEGUB_WAkX_VFKBBtrA@mail.gmail.com>
On Thu, May 23, 2024 at 08:23:57PM +0800, shichao lai wrote:
> On Thu, May 23, 2024 at 7:47 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Thu, May 23, 2024 at 07:34:10PM +0800, Shichao Lai wrote:
> > > Since uzonesize may be zero, so judgements for non-zero
> > > are necessary in both place.
> > >
> > > Changes since v1:
> > > - Add one more check in alauda_write_lba().
> > > - Move check ahead of loop in alauda_read_data().
> >
> > Nit, this changes list should go below the --- line, as the
> > documentation asks for.
>
> Sorry for my inexperience. I have read the document and found some
> examples but I am still a little confused about this.
> I guess this is what you mean?
>
> Since uzonesize may be zero ... (context)
>
> 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().
Yes.
>
> drivers/usb/storage/alauda.c | 4 ++++
> 1 file changed, 4 insertions(+)
> ...
>
>
>
> > Check after the list of variables please, not in the middle of them. I
> > think checkpatch will complain about this, right?
>
> In fact this script doesn't warn about these problems, but I will
> adjust my code style later.
> But the check in alauda_write_lba() is due to some variable like
> lba_offset and zone will perform modulo and divide operations,
> which may throw divide errors when uzonesize is 0.
> So I think I prefer to adjust the order of the variable list later.
> Changes like this.
> ```c
> unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
> unsigned int zonesize = MEDIA_INFO(us).zonesize;
> unsigned int pagesize = MEDIA_INFO(us).pagesize;
> unsigned int blocksize = MEDIA_INFO(us).blocksize;
> unsigned int new_pba_offset;
> if (!uzonesize)
> return USB_STOR_TRANSPORT_ERROR;
> unsigned int lba_offset = lba % uzonesize;
> unsigned int zone = lba / uzonesize;
> ```
> If it's ok, I will post the patch v3 soon.
That works, thanks!
greg k-h
prev parent reply other threads:[~2024-05-23 12:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 11:34 [PATCH v2] usb-storage: Check whether divisor is non-zero before division Shichao Lai
2024-05-23 11:47 ` Greg KH
2024-05-23 12:23 ` shichao lai
2024-05-23 12:37 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024052354-snorkel-drainer-d328@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=samsun1006219@gmail.com \
--cc=shichaorai@gmail.com \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
--cc=xrivendell7@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox