Re: [PATCH 4/4] usbgadget: unregister when usb_composite_probe() fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 27, 2017 at 11:12:45AM +0200, Sascha Hauer wrote:
> When usb_multi_register() returns an error it can't be called again
> as we do not unregister the driver properly. Fix this.
> 
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/multi.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
> index 6385c16186..6eeeb4e982 100644
> --- a/drivers/usb/gadget/multi.c
> +++ b/drivers/usb/gadget/multi.c
> @@ -234,6 +234,8 @@ static struct usb_composite_driver multi_driver = {
>  
>  int usb_multi_register(struct f_multi_opts *opts)
>  {
> +	int ret;
> +
>  	if (gadget_multi_opts) {
>  		pr_err("USB multi gadget already registered\n");
>  		return -EBUSY;
> @@ -241,7 +243,13 @@ int usb_multi_register(struct f_multi_opts *opts)
>  
>  	gadget_multi_opts = opts;
>  
> -	return usb_composite_probe(&multi_driver);
> +	ret = usb_composite_probe(&multi_driver);
> +	if (ret) {
> +		usb_composite_unregister(&multi_driver);
> +		gadget_multi_opts = NULL;
> +	}
> +
> +	return ret;
>  }
>  
>  void usb_multi_unregister(void)
> -- 
> 2.11.0

Reviewed-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux