[PATCH] media: uvcvideo: Fail probe when no video device is registered
From: Chen Changcheng
Date: Tue Nov 03 2026 - 21:26:09 EST
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@xxxxxxxxxx>
---
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