public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Yazan Doofesh <yazan.doofesh@gmail.com>
Cc: linux-media@vger.kernel.org, mchehab@kernel.org
Subject: Re: [PATCH] media: uvcvideo: handle duplicate unit/terminal ID in UVC descriptor
Date: Mon, 16 Mar 2026 16:24:46 +0200	[thread overview]
Message-ID: <20260316142446.GD31604@killaraus.ideasonboard.com> (raw)
In-Reply-To: <CANEv+DwzykgnHxs7GNUrTPFtaavoSWVP-yYikBwA7YXQ9Eq1iw@mail.gmail.com>

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

       reply	other threads:[~2026-03-16 14:24 UTC|newest]

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

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=20260316142446.GD31604@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=yazan.doofesh@gmail.com \
    /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