public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Shichao Lai <shichaorai@gmail.com>,
	stern@rowland.harvard.edu, gregkh@linuxfoundation.org
Cc: 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] Check whether divisor is non-zero before division
Date: Thu, 23 May 2024 10:18:05 +0200	[thread overview]
Message-ID: <a218cac3-9d9d-4ac9-8ea3-0ea9822b2261@suse.com> (raw)
In-Reply-To: <20240523072242.787164-1-shichaorai@gmail.com>

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@gmail.com>
> Reported-by: yue sun <samsun1006219@gmail.com>
> Signed-off-by: Shichao Lai <shichaorai@gmail.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

  parent reply	other threads:[~2024-05-23  8:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23  7:22 [PATCH] Check whether divisor is non-zero before division Shichao Lai
2024-05-23  7:36 ` Greg KH
2024-05-23  8:18 ` Oliver Neukum [this message]
2024-05-23  9:12   ` shichao lai
2024-05-23  9:15     ` Oliver Neukum

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=a218cac3-9d9d-4ac9-8ea3-0ea9822b2261@suse.com \
    --to=oneukum@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --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