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 D0CBD33D4E2; Mon, 13 Apr 2026 17:01:08 +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=1776099668; cv=none; b=N7U0Qih7sFD5u/VHaEdizPJ2orsKhcCUFyjmoH44xCYYF4oQDIAetDAujIW9zoNYQbRousfR7A4hoWnrISiwMOqAKzHVBTqPW36dQV9fwO8Yx3RaGV0FG/B5D1kZfXSKgC7vER87g9ZTORG7md+zPsQtRHDZpIMexLHFMc5r7OQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099668; c=relaxed/simple; bh=L1HhDCToxkHYGV+h+bpHemHv/BUbEGHVV4InX7drzvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j+br3DRNSzXArnCjgwoI3fQKDu6wPWsQEaqFUYNsIi78/JiqwxLlW9FrDnmhHZOhR1VjHaNIWAFaffZK6NPbHcLsWqXz5nsx3O5VHgZdlaeY1E6jjl0tmPoGmziaNcJYxumNg3QyIurCWMTMpQlZsy7bZ7DK9EjLrEAl9GrQ5Ro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Av36WnLn; 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="Av36WnLn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60982C2BCAF; Mon, 13 Apr 2026 17:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776099668; bh=L1HhDCToxkHYGV+h+bpHemHv/BUbEGHVV4InX7drzvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Av36WnLnjY4o2lFtOs9G+2T+NFTlBjPurs32CEQ7y7uZBWeEqsYNqYh0VI3FjNfhX XCky7mif0FRiT1JAy76oOBLeucaF8qQMAz8SapfytPpSoRH9VRN6BzWP5js1tcNiSy gyOlWK4C+wLM7MqKYwPaVSgdXaXTgTQC0MNmwdPU= 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 5.10 429/491] media: uvcvideo: Use heuristic to find stream entity Date: Mon, 13 Apr 2026 18:01:14 +0200 Message-ID: <20260413155835.089793195@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@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 5.10-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 bf1456caae2d2..5c07e79430e93 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -443,13 +443,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