diff mbox series

[v6,4/4] media: uvcvideo: Exit early if there is not int_urb

Message ID 20240614-guenter-mini-v6-4-7b7fdc3b21b3@chromium.org
State Superseded
Headers show
Series uvcvideo: Attempt N to land UVC race conditions fixes | expand

Commit Message

Ricardo Ribalda June 14, 2024, 12:41 p.m. UTC
If there is no int_urb there is no need to do a clean stop.

Also we avoid calling usb_kill_urb(NULL). It is properly handled by the
usb framework, but it is not polite.

Now that we are at it, fix the code style in uvc_status_start() for
consistency.

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_status.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 25, 2024, 7:27 p.m. UTC | #1
Hi Ricardo,

Thank you for the patch.

On Fri, Jun 14, 2024 at 12:41:30PM +0000, Ricardo Ribalda wrote:
> If there is no int_urb there is no need to do a clean stop.
> 
> Also we avoid calling usb_kill_urb(NULL). It is properly handled by the
> usb framework, but it is not polite.
> 
> Now that we are at it, fix the code style in uvc_status_start() for
> consistency.
> 
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/usb/uvc/uvc_status.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c
> index 8fd8250110e2..9108522beea6 100644
> --- a/drivers/media/usb/uvc/uvc_status.c
> +++ b/drivers/media/usb/uvc/uvc_status.c
> @@ -308,7 +308,7 @@ static int __uvc_status_start(struct uvc_device *dev, gfp_t flags)
>  {
>  	lockdep_assert_held(&dev->status_lock);
>  
> -	if (dev->int_urb == NULL)
> +	if (!dev->int_urb)
>  		return 0;
>  
>  	return usb_submit_urb(dev->int_urb, flags);
> @@ -320,6 +320,9 @@ static void __uvc_status_stop(struct uvc_device *dev)
>  
>  	lockdep_assert_held(&dev->status_lock);
>  
> +	if (!dev->int_urb)
> +		return;
> +
>  	/*
>  	 * Prevent the asynchronous control handler from requeing the URB. The
>  	 * barrier is needed so the flush_status change is visible to other
>
diff mbox series

Patch

diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c
index 8fd8250110e2..9108522beea6 100644
--- a/drivers/media/usb/uvc/uvc_status.c
+++ b/drivers/media/usb/uvc/uvc_status.c
@@ -308,7 +308,7 @@  static int __uvc_status_start(struct uvc_device *dev, gfp_t flags)
 {
 	lockdep_assert_held(&dev->status_lock);
 
-	if (dev->int_urb == NULL)
+	if (!dev->int_urb)
 		return 0;
 
 	return usb_submit_urb(dev->int_urb, flags);
@@ -320,6 +320,9 @@  static void __uvc_status_stop(struct uvc_device *dev)
 
 	lockdep_assert_held(&dev->status_lock);
 
+	if (!dev->int_urb)
+		return;
+
 	/*
 	 * Prevent the asynchronous control handler from requeing the URB. The
 	 * barrier is needed so the flush_status change is visible to other