public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Wang Hai <wanghai38@huawei.com>
Cc: oneukum@suse.com, davem@davemloft.net, kuba@kernel.org,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] usbnet: fix error return code in usbnet_probe()
Date: Tue, 26 Oct 2021 13:54:26 +0200	[thread overview]
Message-ID: <YXfsclAOm8Zhbac1@hovoldconsulting.com> (raw)
In-Reply-To: <20211026112526.2878177-1-wanghai38@huawei.com>

On Tue, Oct 26, 2021 at 07:25:26PM +0800, Wang Hai wrote:
> Return error code if usb_maxpacket() returns 0 in usbnet_probe().
> 
> Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---

Good catch. This is embarrassing. I double checked the error path but
failed to notice the missing return value.

>  drivers/net/usb/usbnet.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 80432ee0ce69..fb5bf7d36d50 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1790,6 +1790,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
>  	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
>  	if (dev->maxpacket == 0) {
>  		/* that is a broken device */
> +		status = -EINVAL;

But please use -ENODEV here. -EINVAL is typically reserved for bad user
input.

>  		goto out4;
>  	}

Johan

  reply	other threads:[~2021-10-26 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 11:25 [PATCH net] usbnet: fix error return code in usbnet_probe() Wang Hai
2021-10-26 11:54 ` Johan Hovold [this message]
2021-10-26 12:17   ` wanghai (M)

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=YXfsclAOm8Zhbac1@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=wanghai38@huawei.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