linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	balbi@kernel.org
Subject: Re: [PATCH -next] usb: gadget: hid: fix error return code
Date: Thu, 17 Jun 2021 15:30:31 +0200	[thread overview]
Message-ID: <YMtOd9qsL4D/glmZ@kroah.com> (raw)
In-Reply-To: <20210617065625.1206872-1-yangyingliang@huawei.com>

On Thu, Jun 17, 2021 at 02:56:25PM +0800, Yang Yingliang wrote:
> Fix to return a negative error code from the error handling
> case instead of 0.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/usb/gadget/legacy/hid.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
> index c4eda7fe7ab4..3912cc805f3a 100644
> --- a/drivers/usb/gadget/legacy/hid.c
> +++ b/drivers/usb/gadget/legacy/hid.c
> @@ -99,8 +99,10 @@ static int do_config(struct usb_configuration *c)
>  
>  	list_for_each_entry(e, &hidg_func_list, node) {
>  		e->f = usb_get_function(e->fi);
> -		if (IS_ERR(e->f))
> +		if (IS_ERR(e->f)) {
> +			status = PTR_ERR(e->f);

Are you _SURE_ that you now want to return an error?  This code has
never done this, what is going to break now that it will?

>  			goto put;
> +		}
>  		status = usb_add_function(c, e->f);
>  		if (status < 0) {
>  			usb_put_function(e->f);
> @@ -171,8 +173,10 @@ static int hid_bind(struct usb_composite_dev *cdev)
>  		struct usb_descriptor_header *usb_desc;
>  
>  		usb_desc = usb_otg_descriptor_alloc(gadget);
> -		if (!usb_desc)
> +		if (!usb_desc) {
> +			status = -ENOMEM;

This looks correct, can you resend just this chunk, and then go test the
above change to verify it doesn't break things?

thanks,

greg k-h

      reply	other threads:[~2021-06-17 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  6:56 [PATCH -next] usb: gadget: hid: fix error return code Yang Yingliang
2021-06-17 13:30 ` 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=YMtOd9qsL4D/glmZ@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=balbi@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=yangyingliang@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;
as well as URLs for NNTP newsgroup(s).