Commit c5fe3ed6 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Hans Verkuil
Browse files

media: uvcvideo: Avoid race condition during unregister



The control events are handled asynchronously by the driver. Once the
control event are handled, the urb is re-submitted.

If we simply kill the urb, there is a chance that a control event is
waiting to be processed, which will re-submit the urb after the device is
disconnected.

Fix this by calling uvc_status_suspend(), which flushes the async
controls and kills the URB in a race-free manner.

Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20240926-guenter-mini-v7-2-690441953d4a@chromium.org


Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 44f70338
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ int uvc_status_init(struct uvc_device *dev)

void uvc_status_unregister(struct uvc_device *dev)
{
	usb_kill_urb(dev->int_urb);
	uvc_status_suspend(dev);
	uvc_input_unregister(dev);
}