public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Colin Ian King <colin.i.king@gmail.com>
Cc: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH][next] USB: gadget: Fix return of -EBUSY
Date: Wed, 4 May 2022 10:05:48 -0400	[thread overview]
Message-ID: <YnKIPNtZ0wuPy7oS@rowland.harvard.edu> (raw)
In-Reply-To: <20220504135840.232209-1-colin.i.king@gmail.com>

On Wed, May 04, 2022 at 02:58:40PM +0100, Colin Ian King wrote:
> Currently when driver->match_existing_only is true, the error return is
> set to -EBUSY however ret is then set to 0 at the end of the if/else
> statement. I believe the ret = 0 statement should be set in the else
> part of the if statement and not at the end to ensure -EBUSY is being
> returned correctly.
> 
> Detected by clang scan:
> drivers/usb/gadget/udc/core.c:1558:4: warning: Value stored to 'ret' is
> never read [deadcode.DeadStores]
> 
> Fixes: fc274c1e9973 ("USB: gadget: Add a new bus for gadgets")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Don't know how I missed that.  Thanks for fixing it.

In fact, since it's guaranteed that ret is already 0 before the 
driver->match_existing_only test, you could eliminate the assignment 
entirely.  But moving it into the second branch of the "if" statement is 
probably more clear.

Alan Stern

>  drivers/usb/gadget/udc/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 61790592b2c8..3281d8a3dae7 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -1559,8 +1559,8 @@ int usb_gadget_register_driver_owner(struct usb_gadget_driver *driver,
>  		} else {
>  			pr_info("%s: couldn't find an available UDC\n",
>  					driver->function);
> +			ret = 0;
>  		}
> -		ret = 0;
>  	}
>  	mutex_unlock(&udc_lock);
>  
> -- 
> 2.35.1
> 

      reply	other threads:[~2022-05-04 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 13:58 [PATCH][next] USB: gadget: Fix return of -EBUSY Colin Ian King
2022-05-04 14:05 ` Alan Stern [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=YnKIPNtZ0wuPy7oS@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=balbi@kernel.org \
    --cc=colin.i.king@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    /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