Re: [PATCH v2] usb: gadget: uvc: don't put item still in use

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

 



Hi Michael,

(Cc'ing Kieran and Dan)

Thank you for the patch.

On Fri, Sep 30, 2022 at 02:28:39PM +0200, Michael Grzeschik wrote:
> With the patch "588b9e85609b (usb: gadget: uvc: add v4l2 enumeration api
> calls)" the driver is keeping a list of configfs entries currently
> configured. The list is used in uvc_v4l2 on runtime.

s/on runtime/at runtime/

> The driver now is giving back the list item just after it was referenced
> with config_item_put. It also calls config_item_put on uvc_free, which
> is the only and right place to give back the reference. This patch fixes
> the issue by removing the extra config_item_put in uvc_alloc.
> 
> Fixes: 588b9e85609b (usb: gadget: uvc: add v4l2 enumeration api calls)

I still don't like this much :-( As shown by this fix, the additional
complexity that it incurs on the kernel side can cause bugs, and the
gain for userspace is quite minimal in my opinion, as parsing configfs
(or obtaining that information out-of-band through other means) will
still be needed anyway to handle controls properly (I think we have
agreed that userspace needs to handle the UVC requests in any case).

> Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
> ---
> v1 -> v2: - fixed commitish to valid one from usb-next tree
> 
>  drivers/usb/gadget/function/f_uvc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
> index e6948cf8def30b..8bc591431d153e 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -995,7 +995,6 @@ static struct usb_function *uvc_alloc(struct usb_function_instance *fi)
>  		goto err_config;
>  
>  	uvc->header = to_uvcg_streaming_header(h);
> -	config_item_put(h);

Assuming we want to keep 588b9e85609b, the fix seems right.

>  	if (!uvc->header->linked) {
>  		mutex_unlock(&opts->lock);
>  		kfree(uvc);

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux