linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Tomasz Figa <tfiga@chromium.org>,
	 Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 Alan Stern <stern@rowland.harvard.edu>,
	 Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	linux-media@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Sean Paul <seanpaul@chromium.org>,
	 Ricardo Ribalda <ribalda@chromium.org>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: [PATCH v5 4/4] media: uvcvideo: Exit early if there is not int_urb
Date: Tue, 11 Jun 2024 08:12:09 +0000	[thread overview]
Message-ID: <20240611-guenter-mini-v5-4-047b6fe5d08b@chromium.org> (raw)
In-Reply-To: <20240611-guenter-mini-v5-0-047b6fe5d08b@chromium.org>

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.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 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

-- 
2.45.2.505.gda0bf45e8d-goog


      parent reply	other threads:[~2024-06-11  8:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11  8:12 [PATCH v5 0/4] uvcvideo: Attempt N to land UVC race conditions fixes Ricardo Ribalda
2024-06-11  8:12 ` [PATCH v5 1/4] media: uvcvideo: stop stream during unregister Ricardo Ribalda
2024-06-14  9:02   ` Hans Verkuil
2024-06-11  8:12 ` [PATCH v5 2/4] media: uvcvideo: Refactor the status irq API Ricardo Ribalda
2024-06-11  8:12 ` [PATCH v5 3/4] media: uvcvideo: Avoid race condition during unregister Ricardo Ribalda
2024-06-11  8:12 ` Ricardo Ribalda [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240611-guenter-mini-v5-4-047b6fe5d08b@chromium.org \
    --to=ribalda@chromium.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=seanpaul@chromium.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).