Re: [PATCH 1/2] usb: gadget: f_uac2: improve error handling

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

 



On Wed, Jan 04, 2017 at 10:19:22AM +0800, Peter Chen wrote:
> If it is out of memory, we should return -ENOMEM;
> 
> Signed-off-by: Peter Chen <peter.chen@xxxxxxx>
> ---
>  drivers/usb/gadget/function/f_uac2.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
> index 969cfe7..3f4e478 100644
> --- a/drivers/usb/gadget/function/f_uac2.c
> +++ b/drivers/usb/gadget/function/f_uac2.c
> @@ -1098,6 +1098,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
>  	if (!prm->rbuf) {
>  		prm->max_psize = 0;
> +		ret = -ENOMEM;
>  		goto err_free_descs;
>  	}
>  
> @@ -1106,20 +1107,21 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
>  	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
>  	if (!prm->rbuf) {
>  		prm->max_psize = 0;
> -		goto err;
> +		ret = -ENOMEM;
> +		goto err_no_memory;
>  	}
>  
>  	ret = alsa_uac2_init(agdev);
>  	if (ret)
> -		goto err;
> +		goto err_no_memory;
>  	return 0;
>  
> -err:
> +err_no_memory:
>  	kfree(agdev->uac2.p_prm.rbuf);
>  	kfree(agdev->uac2.c_prm.rbuf);
>  err_free_descs:
>  	usb_free_all_descriptors(fn);
> -	return -EINVAL;
> +	return ret;
>  }
>  
>  static int
> -- 

A nice ping...

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux