mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 Hans de Goede <hansg@kernel.org>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Hans Verkuil <hverkuil@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Nezul Tairus <radwolf.83@gmail.com>,
	Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH] media: uvcvideo: Return -EINVAL for ctrl_get errors on disabled controls
Date: Wed, 25 Nov 2026 13:35:33 +0000	[thread overview]
Message-ID: <20261125-uvc-invalid-einval-v1-1-57e34bd8ce06@chromium.org> (raw)

Some non-compliant cameras fail boundary queries (e.g. GET_MIN), so
uvcvideo marks those controls as disabled during enumeration. Due to
legacy uAPI constraints, GET_CUR requests are still sent to the hardware
for disabled controls.

However, userspace (e.g. PipeWire) expects -EINVAL for disabled controls
and treats -EIO as a fatal error, which can cause it to disable the
camera completely.

Match the V4L2 control framework behaviour in uvc_ctrl_get() for
VIDIOC_G_EXT_CTRLS returning -EINVAL directly for boundary queries
(V4L2_CTRL_WHICH_{DEF,MIN,MAX}_VAL) on disabled controls, and converting
-EIO from GET_CUR into -EINVAL. If GET_CUR succeeds, the value is still
returned to the user.

Reported-by: Nezul Tairus <radwolf.83@gmail.com>
Closes: https://lore.kernel.org/linux-media/CAFDWN6LPcz6CBOZzBVN-VbCce3g2wOrPZ8V45_=8xv16VCqzsg@mail.gmail.com/T/#u
Fixes: 649c033711d7 ("media: uvcvideo: Set V4L2_CTRL_FLAG_DISABLED during queryctrl errors")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index d2f722bc3459..9390cb642d30 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2645,6 +2645,7 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which,
 {
 	struct uvc_control *ctrl;
 	struct uvc_control_mapping *mapping;
+	int ret;
 
 	if (__uvc_query_v4l2_class(chain, xctrl->id, 0) >= 0)
 		return -EACCES;
@@ -2653,7 +2654,14 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which,
 	if (!ctrl)
 		return -EINVAL;
 
-	return uvc_mapping_get_xctrl(chain, ctrl, mapping, which, xctrl);
+	if (mapping->disabled && which != V4L2_CTRL_WHICH_CUR_VAL)
+		return -EINVAL;
+
+	ret = uvc_mapping_get_xctrl(chain, ctrl, mapping, which, xctrl);
+	if (ret == -EIO && mapping->disabled)
+		return -EINVAL;
+
+	return ret;
 }
 
 static int uvc_ctrl_clamp(struct uvc_video_chain *chain,

---
base-commit: b7ac871daee981f1963f632586ff9b9d898ce5dd
change-id: 20261125-uvc-invalid-einval-603b8f0bda56

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>


                 reply	other threads:[~2026-11-25 13:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261125-uvc-invalid-einval-v1-1-57e34bd8ce06@chromium.org \
    --to=ribalda@chromium.org \
    --cc=hansg@kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=radwolf.83@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

all inboxes | Powered by JetHome®