public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] media: uvcvideo: handle duplicate unit/terminal ID in UVC descriptor
       [not found] <CANEv+DwzykgnHxs7GNUrTPFtaavoSWVP-yYikBwA7YXQ9Eq1iw@mail.gmail.com>
@ 2026-03-16 14:24 ` Laurent Pinchart
       [not found]   ` <CANEv+DydTW1-UoMH6=3X_6ijSb99jirdDCSBzx7QPQZNVpdYHg@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2026-03-16 14:24 UTC (permalink / raw)
  To: Yazan Doofesh; +Cc: linux-media, mchehab

On Mon, Mar 16, 2026 at 05:18:45PM +0300, Yazan Doofesh wrote:
> Hello,
> 
> Some cameras incorrectly assign the same ID to both a processing unit and an
> output terminal in their UVC VideoControl descriptor. When uvc_alloc_new_entity
> () detects the duplicate, it currently invalidates the new entity's ID. If the
> new entity is the output terminal, the streaming interface (which links to that
> terminal by ID) can no longer find it, and no /dev/video* node is created.
> 
> The kernel log for such a device shows: uvcvideo 1-2.3:1.0: Found multiple
> Units with ID 5 usb 1-2.3: No streaming interface found for terminal 65535.
> 
> The "65535" (0xffff = UVC_INVALID_ENTITY_ID) confirms the terminal's ID was
> overwritten.
> 
> Fix: when the incoming entity is an output terminal and the conflicting entity
> is a unit, remove the unit from the entity list and allow the terminal to keep
> the original ID. This is safe during the parsing phase because chain-building
> has not yet begun.
> 
> Tested with: Generalplus Technology Inc. GENERAL WEBCAM (idVendor=1b3f,
> idProduct=2247). The camera works on Windows (which tolerates the malformed
> descriptor) but produced no /dev/video* node on Linux prior to this fix.
> 
> USB descriptor excerpt showing the conflict: VideoControl Interface Descriptor:
> bUnitID 5 bSourceID 4 VideoControl Interface Descriptor: bTerminalID 5
> wTerminalType 0x0101 USB Streaming bSourceID 4 VideoStreaming Interface
> Descriptor: bTerminalLink 5
> 
> Note: this patch was diagnosed and written with the assistance of Claude
> (Anthropic AI). The fix has been tested and confirmed working on kernel 6.17.7.

NAK. Please don't waste my time with LLM-generated contents. The next
attempt will result in your e-mail address being added to my block list.

> Signed-off-by: Yazan Doofesh <yazan.doofesh@gmail.com>
> 
> drivers/media/usb/uvc/uvc_driver.c | 21 ++++++++++++++++----- 1 file changed,
> 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/
> uvc_driver.c index 50e158966..39fbdc166 100644 --- a/drivers/media/usb/uvc/
> uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -814,9 +814,26 @@
> static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev, u16
> type, }
> 
> /* Per UVC 1.1+ spec 3.7.2, the ID is unique. */
> 
>   • if (uvc_entity_by_id(dev, id)) {
>   •   dev_err(&dev->intf->dev, "Found multiple Units with ID %u\n", id);
> 
>   •   id = UVC_INVALID_ENTITY_ID;
> 
>   • {
> 
>   •   struct uvc_entity *conflict = uvc_entity_by_id(dev, id);
> 
>   • 
>   •   if (conflict) {
> 
>   •         dev_warn(&dev->intf->dev,
> 
>   •                  "Found multiple Units with ID %u\n", id);
> 
>   •         if (type & UVC_TERM_OUTPUT) {
> 
>   •                 /*
> 
>   •                  * Some cameras (e.g. Generalplus 1b3f:2247)
> 
>   •                  * incorrectly assign the same ID to both a unit
> 
>   •                  * and an output terminal. The streaming interface
> 
>   •                  * links to the terminal by ID, so drop the
> 
>   •                  * conflicting unit and keep the terminal's ID.
> 
>   •                  */
> 
>   •                 list_del(&conflict->list);
> 
>   •                 kfree(conflict);
> 
>   •         } else {
> 
>   •                 id = UVC_INVALID_ENTITY_ID;
> 
>   •         }
> 
>   •   }
> 
>     }
> 
>     extra_size = roundup(extra_size, sizeof(*entity->pads));
> 
>   • 
> 
> Yazan Doofesh
> 
> Project Manager
> Tel: +926 799 866 381
> Amman, Jordan

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] media: uvcvideo: handle duplicate unit/terminal ID in UVC descriptor
       [not found]   ` <CANEv+DydTW1-UoMH6=3X_6ijSb99jirdDCSBzx7QPQZNVpdYHg@mail.gmail.com>
@ 2026-03-20 12:05     ` Laurent Pinchart
       [not found]       ` <CANEv+Dx-hcy-eS+N6X4MNPwvxD-xYetM46w_jNZdFrvLF+mKaA@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2026-03-20 12:05 UTC (permalink / raw)
  To: Yazan Doofesh; +Cc: linux-media, mchehab

On Thu, Mar 19, 2026 at 09:42:58PM +0300, Yazan Doofesh wrote:
> Sorry, I didn't realize this was a faux pas. I'm not a developer and I
> thought this would be a positive contribution as it actually worked for me
> as described.

The Linux kernel, like many open-source projects, suffers from an
imbalance between contributors and maintainers. There is far more
contributors than maintainers, and therefore maintainer time is a
precious resource. It's hard enough for maintainers to deal with
contributions submitted by developers who understand what they're doing.
Contributions generated by a machine without being 100% validated by the
submitter are simply not sustainable, and are not welcome. This means
that a submitter is expected to have a precise understanding of what a
patch does, how it does it, and why it's the best approach.

We welcome new contributors who are interested in learning.

I do appreciate that your patch disclosed it was generated by an LLM
(although I would have guessed anyway).

In this particular case, the bug you've encountered should already be
fixed in commit 3d9f32e02c2e ("media: uvcvideo: Create an ID namespace
for streaming output terminals"), which will appear in kernel v7.0.

> I genuinely appreciate Bazzite and wished to contribute. I've only recently
> left Windows after 25 years, and am still new to all this.
>
> On Mon, Mar 16, 2026, 17:24 Laurent Pinchart wrote:
> > On Mon, Mar 16, 2026 at 05:18:45PM +0300, Yazan Doofesh wrote:
> > > Hello,
> > >
> > > Some cameras incorrectly assign the same ID to both a processing unit and an
> > > output terminal in their UVC VideoControl descriptor. When uvc_alloc_new_entity
> > > () detects the duplicate, it currently invalidates the new entity's ID. If the
> > > new entity is the output terminal, the streaming interface (which links to that
> > > terminal by ID) can no longer find it, and no /dev/video* node is created.
> > >
> > > The kernel log for such a device shows: uvcvideo 1-2.3:1.0: Found multiple
> > > Units with ID 5 usb 1-2.3: No streaming interface found for terminal 65535.
> > >
> > > The "65535" (0xffff = UVC_INVALID_ENTITY_ID) confirms the terminal's ID was
> > > overwritten.
> > >
> > > Fix: when the incoming entity is an output terminal and the conflicting entity
> > > is a unit, remove the unit from the entity list and allow the terminal to keep
> > > the original ID. This is safe during the parsing phase because chain-building
> > > has not yet begun.
> > >
> > > Tested with: Generalplus Technology Inc. GENERAL WEBCAM (idVendor=1b3f,
> > > idProduct=2247). The camera works on Windows (which tolerates the malformed
> > > descriptor) but produced no /dev/video* node on Linux prior to this fix.
> > >
> > > USB descriptor excerpt showing the conflict: VideoControl Interface Descriptor:
> > > bUnitID 5 bSourceID 4 VideoControl Interface Descriptor: bTerminalID 5
> > > wTerminalType 0x0101 USB Streaming bSourceID 4 VideoStreaming Interface
> > > Descriptor: bTerminalLink 5
> > >
> > > Note: this patch was diagnosed and written with the assistance of Claude
> > > (Anthropic AI). The fix has been tested and confirmed working on kernel 6.17.7.
> >
> > NAK. Please don't waste my time with LLM-generated contents. The next
> > attempt will result in your e-mail address being added to my block list.
> >
> > > Signed-off-by: Yazan Doofesh <yazan.doofesh@gmail.com>
> > >
> > > drivers/media/usb/uvc/uvc_driver.c | 21 ++++++++++++++++-----
> > > 1 file changed, 16 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/
> > > uvc_driver.c index 50e158966..39fbdc166 100644 ---
> > a/drivers/media/usb/uvc/
> > > uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -814,9 +814,26
> > @@
> > > static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev,
> > u16
> > > type, }
> > >
> > > /* Per UVC 1.1+ spec 3.7.2, the ID is unique. */
> > >
> > >   • if (uvc_entity_by_id(dev, id)) {
> > >   •   dev_err(&dev->intf->dev, "Found multiple Units with ID %u\n", id);
> > >
> > >   •   id = UVC_INVALID_ENTITY_ID;
> > >
> > >   • {
> > >
> > >   •   struct uvc_entity *conflict = uvc_entity_by_id(dev, id);
> > >
> > >   •
> > >   •   if (conflict) {
> > >
> > >   •         dev_warn(&dev->intf->dev,
> > >
> > >   •                  "Found multiple Units with ID %u\n", id);
> > >
> > >   •         if (type & UVC_TERM_OUTPUT) {
> > >
> > >   •                 /*
> > >
> > >   •                  * Some cameras (e.g. Generalplus 1b3f:2247)
> > >
> > >   •                  * incorrectly assign the same ID to both a unit
> > >
> > >   •                  * and an output terminal. The streaming interface
> > >
> > >   •                  * links to the terminal by ID, so drop the
> > >
> > >   •                  * conflicting unit and keep the terminal's ID.
> > >
> > >   •                  */
> > >
> > >   •                 list_del(&conflict->list);
> > >
> > >   •                 kfree(conflict);
> > >
> > >   •         } else {
> > >
> > >   •                 id = UVC_INVALID_ENTITY_ID;
> > >
> > >   •         }
> > >
> > >   •   }
> > >
> > >     }
> > >
> > >     extra_size = roundup(extra_size, sizeof(*entity->pads));
> > >
> > >   •
> > >
> > > Yazan Doofesh
> > >
> > > Project Manager
> > > Tel: +926 799 866 381
> > > Amman, Jordan

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] media: uvcvideo: handle duplicate unit/terminal ID in UVC descriptor
       [not found]       ` <CANEv+Dx-hcy-eS+N6X4MNPwvxD-xYetM46w_jNZdFrvLF+mKaA@mail.gmail.com>
@ 2026-03-23 21:53         ` Laurent Pinchart
  0 siblings, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2026-03-23 21:53 UTC (permalink / raw)
  To: Yazan Doofesh; +Cc: linux-media, mchehab

On Tue, Mar 24, 2026 at 12:35:54AM +0300, Yazan Doofesh wrote:
> Thank you Laurent for the explanation and the pointer to the upstream fix,
> I appreciate the time!
> 
> I understand the situation as I have read more about it, and I wish you all
> the best. Should I have anything to report in the future, I will make sure
> I fully understand what I'm submitting before doing so.
> 
> Regards,
> 
> Yazan
> 
> ---
> 
> Kept it short and dignified. The second paragraph shows you absorbed the
> lesson without being overly apologetic.
> 
> Yazan

I have to reply to this for posterity, as the original e-mail was in
HTML and does not show up in the mailing list archive.

> On Fri, 20 Mar 2026 at 15:05, Laurent Pinchart wrote:
> > On Thu, Mar 19, 2026 at 09:42:58PM +0300, Yazan Doofesh wrote:
> > > Sorry, I didn't realize this was a faux pas. I'm not a developer and I
> > > thought this would be a positive contribution as it actually worked for me
> > > as described.
> >
> > The Linux kernel, like many open-source projects, suffers from an
> > imbalance between contributors and maintainers. There is far more
> > contributors than maintainers, and therefore maintainer time is a
> > precious resource. It's hard enough for maintainers to deal with
> > contributions submitted by developers who understand what they're doing.
> > Contributions generated by a machine without being 100% validated by the
> > submitter are simply not sustainable, and are not welcome. This means
> > that a submitter is expected to have a precise understanding of what a
> > patch does, how it does it, and why it's the best approach.
> >
> > We welcome new contributors who are interested in learning.
> >
> > I do appreciate that your patch disclosed it was generated by an LLM
> > (although I would have guessed anyway).
> >
> > In this particular case, the bug you've encountered should already be
> > fixed in commit 3d9f32e02c2e ("media: uvcvideo: Create an ID namespace
> > for streaming output terminals"), which will appear in kernel v7.0.
> >
> > > I genuinely appreciate Bazzite and wished to contribute. I've only recently
> > > left Windows after 25 years, and am still new to all this.
> > >
> > > On Mon, Mar 16, 2026, 17:24 Laurent Pinchart wrote:
> > > > On Mon, Mar 16, 2026 at 05:18:45PM +0300, Yazan Doofesh wrote:
> > > > > Hello,
> > > > >
> > > > > Some cameras incorrectly assign the same ID to both a processing unit and an
> > > > > output terminal in their UVC VideoControl descriptor. When uvc_alloc_new_entity
> > > > > () detects the duplicate, it currently invalidates the new entity's ID. If the
> > > > > new entity is the output terminal, the streaming interface (which links to that
> > > > > terminal by ID) can no longer find it, and no /dev/video* node is created.
> > > > >
> > > > > The kernel log for such a device shows: uvcvideo 1-2.3:1.0: Found multiple
> > > > > Units with ID 5 usb 1-2.3: No streaming interface found for terminal 65535.
> > > > >
> > > > > The "65535" (0xffff = UVC_INVALID_ENTITY_ID) confirms the terminal's ID was
> > > > > overwritten.
> > > > >
> > > > > Fix: when the incoming entity is an output terminal and the conflicting entity
> > > > > is a unit, remove the unit from the entity list and allow the terminal to keep
> > > > > the original ID. This is safe during the parsing phase because chain-building
> > > > > has not yet begun.
> > > > >
> > > > > Tested with: Generalplus Technology Inc. GENERAL WEBCAM (idVendor=1b3f,
> > > > > idProduct=2247). The camera works on Windows (which tolerates the malformed
> > > > > descriptor) but produced no /dev/video* node on Linux prior to this fix.
> > > > >
> > > > > USB descriptor excerpt showing the conflict: VideoControl Interface Descriptor:
> > > > > bUnitID 5 bSourceID 4 VideoControl Interface Descriptor: bTerminalID 5
> > > > > wTerminalType 0x0101 USB Streaming bSourceID 4 VideoStreaming Interface
> > > > > Descriptor: bTerminalLink 5
> > > > >
> > > > > Note: this patch was diagnosed and written with the assistance of Claude
> > > > > (Anthropic AI). The fix has been tested and confirmed working on kernel 6.17.7.
> > > >
> > > > NAK. Please don't waste my time with LLM-generated contents. The next
> > > > attempt will result in your e-mail address being added to my block list.
> > > >
> > > > > Signed-off-by: Yazan Doofesh <yazan.doofesh@gmail.com>
> > > > >
> > > > > drivers/media/usb/uvc/uvc_driver.c | 21 ++++++++++++++++-----
> > > > > 1 file changed, 16 insertions(+), 5 deletions(-)
> > > > >
> > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/
> > > > > uvc_driver.c index 50e158966..39fbdc166 100644 ---
> > > > a/drivers/media/usb/uvc/
> > > > > uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c
> > > > @@ -814,9 +814,26 @@
> > > > > static struct uvc_entity *uvc_alloc_new_entity(struct uvc_device *dev, u16
> > > > > type, }
> > > > >
> > > > > /* Per UVC 1.1+ spec 3.7.2, the ID is unique. */
> > > > >
> > > > >   • if (uvc_entity_by_id(dev, id)) {
> > > > >   •   dev_err(&dev->intf->dev, "Found multiple Units with ID %u\n", id);
> > > > >
> > > > >   •   id = UVC_INVALID_ENTITY_ID;
> > > > >
> > > > >   • {
> > > > >
> > > > >   •   struct uvc_entity *conflict = uvc_entity_by_id(dev, id);
> > > > >
> > > > >   •
> > > > >   •   if (conflict) {
> > > > >
> > > > >   •         dev_warn(&dev->intf->dev,
> > > > >
> > > > >   •                  "Found multiple Units with ID %u\n", id);
> > > > >
> > > > >   •         if (type & UVC_TERM_OUTPUT) {
> > > > >
> > > > >   •                 /*
> > > > >
> > > > >   •                  * Some cameras (e.g. Generalplus 1b3f:2247)
> > > > >
> > > > >   •                  * incorrectly assign the same ID to both a unit
> > > > >
> > > > >   •                  * and an output terminal. The streaming interface
> > > > >
> > > > >   •                  * links to the terminal by ID, so drop the
> > > > >
> > > > >   •                  * conflicting unit and keep the terminal's ID.
> > > > >
> > > > >   •                  */
> > > > >
> > > > >   •                 list_del(&conflict->list);
> > > > >
> > > > >   •                 kfree(conflict);
> > > > >
> > > > >   •         } else {
> > > > >
> > > > >   •                 id = UVC_INVALID_ENTITY_ID;
> > > > >
> > > > >   •         }
> > > > >
> > > > >   •   }
> > > > >
> > > > >     }
> > > > >
> > > > >     extra_size = roundup(extra_size, sizeof(*entity->pads));
> > > > >
> > > > >   •
> > > > >
> > > > > Yazan Doofesh
> > > > >
> > > > > Project Manager
> > > > > Tel: +926 799 866 381
> > > > > Amman, Jordan

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2026-03-23 21:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CANEv+DwzykgnHxs7GNUrTPFtaavoSWVP-yYikBwA7YXQ9Eq1iw@mail.gmail.com>
2026-03-16 14:24 ` [PATCH] media: uvcvideo: handle duplicate unit/terminal ID in UVC descriptor Laurent Pinchart
     [not found]   ` <CANEv+DydTW1-UoMH6=3X_6ijSb99jirdDCSBzx7QPQZNVpdYHg@mail.gmail.com>
2026-03-20 12:05     ` Laurent Pinchart
     [not found]       ` <CANEv+Dx-hcy-eS+N6X4MNPwvxD-xYetM46w_jNZdFrvLF+mKaA@mail.gmail.com>
2026-03-23 21:53         ` Laurent Pinchart

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