mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: uvcvideo: Fail probe when no video device is registered
@ 2026-11-04  2:21 Chen Changcheng
  2026-11-04  6:04 ` Laurent Pinchart
  2026-11-04  7:41 ` Laurent Pinchart
  0 siblings, 2 replies; 4+ messages in thread
From: Chen Changcheng @ 2026-11-04  2:21 UTC (permalink / raw)
  To: Laurent Pinchart, Hans de Goede, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, Chen Changcheng

When a UVC device is unbound while userspace still holds the video
device open, the VS interface claims are released only after the last
file descriptor is closed.  Rebinding before that fails to claim the VS
interfaces, leaving the VC interface bound without a usable video
device:

  [ 3229.189556] uvcvideo: Probing generic UVC device 1
  [ 3229.190496] uvcvideo: device 2 interface 1 is already claimed
  ...
  [ 3229.193758] uvcvideo: Scanning UVC chain: OT 4 <- XU 3 <- PU 2 <- IT 1
  [ 3229.193766] uvcvideo: Found a valid video chain (1 -> 4).
  [ 3229.193771] usb 9-1: No streaming interface found for terminal 4.

Check after registering all video chains that at least one video device
was registered, and fail the probe with -ENODEV otherwise.

Devices with no usable streaming interface at all will now also stay
unbound instead of being bound without any video device.

Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
---
 drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index e289cc71ba98..0943db4eae07 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2156,6 +2156,19 @@ static int uvc_register_terms(struct uvc_device *dev,
 	return 0;
 }
 
+static int uvc_has_video_node(struct uvc_device *dev)
+{
+	struct uvc_streaming *stream;
+
+	list_for_each_entry(stream, &dev->streams, list)
+		if (video_is_registered(&stream->queue.vdev))
+			return 0;
+
+	dev_info(&dev->intf->dev,
+		 "No usable streaming interface found\n");
+	return -ENODEV;
+}
+
 static int uvc_register_chains(struct uvc_device *dev)
 {
 	struct uvc_video_chain *chain;
@@ -2174,7 +2187,7 @@ static int uvc_register_chains(struct uvc_device *dev)
 #endif
 	}
 
-	return 0;
+	return uvc_has_video_node(dev);
 }
 
 /* ------------------------------------------------------------------------

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-04  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04  2:21 [PATCH] media: uvcvideo: Fail probe when no video device is registered Chen Changcheng
2026-11-04  6:04 ` Laurent Pinchart
2026-11-04  7:21   ` Chen Changcheng
2026-11-04  7:41 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®