From: Chen Changcheng <chenchangcheng@kylinos.cn>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Chen Changcheng <chenchangcheng@kylinos.cn>
Subject: [PATCH] media: uvcvideo: Fail probe when no video device is registered
Date: Wed, 4 Nov 2026 10:21:46 +0800 [thread overview]
Message-ID: <20261104022146.42954-1-chenchangcheng@kylinos.cn> (raw)
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
next reply other threads:[~2026-11-04 2:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 2:21 Chen Changcheng [this message]
2026-11-04 6:04 ` Laurent Pinchart
2026-11-04 7:21 ` Chen Changcheng
2026-11-04 7:41 ` Laurent Pinchart
2026-11-06 2:26 ` Chen Changcheng
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=20261104022146.42954-1-chenchangcheng@kylinos.cn \
--to=chenchangcheng@kylinos.cn \
--cc=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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
all inboxes | Powered by JetHome®