From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5B526CE32; Mon, 13 Apr 2026 16:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096967; cv=none; b=FGmbl0/f7sxBnLYToZtkNyHfR1IMUfi5IWCdYUhEJKbQ65IQ3r2r9XpklQqnOULOfM7SCVsdePeUtGgtrcc8r1+RZf9ADQAoMFALocSy+se+6N+Ci+XeMPnPCct0mwCHmnKVWtFDtiSk/B/1+ER2To9d4fb+fcameLKnvI7B3QU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096967; c=relaxed/simple; bh=x/pa0LXevOc+9K11UNUI4WWPUxdjgk7Zfhe4WXtD1IA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nwDAA9g4GtswiAL1LKydyFIyGoN8XP7P+5OHZKiZgINclyvJVJ4JvghNaWML6a1Z/x0jzFwOq1bwSckQobQfrFJRojo3x8Q+EXehcLUG6EsUgOvfq8bc2NhL5sQ+xhrjoVfG/7wdK3c/+WcDSv0zdOAmIbm5g6iIwY1ZJj0UDu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QhOQ0AUU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QhOQ0AUU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 253D4C2BCAF; Mon, 13 Apr 2026 16:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776096967; bh=x/pa0LXevOc+9K11UNUI4WWPUxdjgk7Zfhe4WXtD1IA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QhOQ0AUUOD5+YtEDENScAlGWCmJRsxqtFv2yPJ/etbrQCo/M9UB0Lu/cf39tSneR1 c2Ete/dO3bO5ccfa+7/ptVwGV7qo9DMM64pIzDcgEChE/27sXKhdUwL4oHRQuzYvOI W6NCDcZu1j1y7eeHwH0475wxLvK41RLFmXQ112WE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Angel4005 , Ricardo Ribalda , Hans de Goede , Hans Verkuil , Sasha Levin Subject: [PATCH 6.1 11/55] media: uvcvideo: Use heuristic to find stream entity Date: Mon, 13 Apr 2026 18:00:45 +0200 Message-ID: <20260413155725.250398787@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155724.820472494@linuxfoundation.org> References: <20260413155724.820472494@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Ribalda [ Upstream commit 758dbc756aad429da11c569c0d067f7fd032bcf7 ] Some devices, like the Grandstream GUV3100 webcam, have an invalid UVC descriptor where multiple entities share the same ID, this is invalid and makes it impossible to make a proper entity tree without heuristics. We have recently introduced a change in the way that we handle invalid entities that has caused a regression on broken devices. Implement a new heuristic to handle these devices properly. Reported-by: Angel4005 Closes: https://lore.kernel.org/linux-media/CAOzBiVuS7ygUjjhCbyWg-KiNx+HFTYnqH5+GJhd6cYsNLT=DaA@mail.gmail.com/ Fixes: 0e2ee70291e6 ("media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID") Cc: stable@vger.kernel.org Signed-off-by: Ricardo Ribalda Reviewed-by: Hans de Goede Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- 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 f81bddd20bc09..a1c6ae97a2b93 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -164,13 +164,26 @@ static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev, static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id) { - struct uvc_streaming *stream; + struct uvc_streaming *stream, *last_stream; + unsigned int count = 0; list_for_each_entry(stream, &dev->streams, list) { + count += 1; + last_stream = stream; if (stream->header.bTerminalLink == id) return stream; } + /* + * If the streaming entity is referenced by an invalid ID, notify the + * user and use heuristics to guess the correct entity. + */ + if (count == 1 && id == UVC_INVALID_ENTITY_ID) { + dev_warn(&dev->intf->dev, + "UVC non compliance: Invalid USB header. The streaming entity has an invalid ID, guessing the correct one."); + return last_stream; + } + return NULL; } -- 2.53.0