Re: [PATCHv2 2/3] usb: gadget: uvc: verify descriptors presence

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

 



Hi Andrzej,

Thank you for the patch.

On Friday 05 December 2014 15:16:35 Andrzej Pietrasiewicz wrote:
> If the caller of uvc_alloc() does not provide enough
> descriptors, binding the function should fail, so appropriate
> code is returned from uvc_copy_descriptors().
> 
> uvc_function_bind() is modified accordingly to account for possible
> errors from uvc_copy_descriptors().
> 
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/f_uvc.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c
> b/drivers/usb/gadget/function/f_uvc.c index 5b4ab39..b14c599 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -508,6 +508,8 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum
> usb_device_speed speed) uvc_streaming_std = uvc_fs_streaming;
>  		break;
>  	}

Nitpicking, could you please insert a blank line here ? With this changed,

Acked-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

> +	if (!uvc_control_desc || !uvc_streaming_cls)
> +		return ERR_PTR(-ENODEV);
> 
>  	/* Descriptors layout
>  	 *
> @@ -700,10 +702,27 @@ uvc_function_bind(struct usb_configuration *c, struct
> usb_function *f)
> 
>  	/* Copy descriptors */
>  	f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
> -	if (gadget_is_dualspeed(cdev->gadget))
> +	if (IS_ERR(f->fs_descriptors)) {
> +		ret = PTR_ERR(f->fs_descriptors);
> +		f->fs_descriptors = NULL;
> +		goto error;
> +	}
> +	if (gadget_is_dualspeed(cdev->gadget)) {
>  		f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
> -	if (gadget_is_superspeed(c->cdev->gadget))
> +		if (IS_ERR(f->hs_descriptors)) {
> +			ret = PTR_ERR(f->hs_descriptors);
> +			f->hs_descriptors = NULL;
> +			goto error;
> +		}
> +	}
> +	if (gadget_is_superspeed(c->cdev->gadget)) {
>  		f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER);
> +		if (IS_ERR(f->ss_descriptors)) {
> +			ret = PTR_ERR(f->ss_descriptors);
> +			f->ss_descriptors = NULL;
> +			goto error;
> +		}
> +	}
> 
>  	/* Preallocate control endpoint request. */
>  	uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);

-- 
Regards,

Laurent Pinchart

--
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