[PATCH v6 04/17] media: v4l2-ioctl: check_ext_ctrls: Fix V4L2_CTRL_WHICH_DEF_VAL

From: Ricardo Ribalda
Date: Wed Mar 17 2021 - 12:46:06 EST


Drivers that do not use the ctrl-framework use this function instead.

Default value cannot be changed, return EINVAL as soon as possible.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 6fa6f831f095 ("media: v4l2-ctrls: add core request support")
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-ioctl.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 528eb5f420f6..ccd21b4d9c72 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -929,6 +929,13 @@ static bool check_ext_ctrls(struct v4l2_ext_controls *c, unsigned long ioctl)
return false;
break;
case V4L2_CTRL_WHICH_DEF_VAL:
+ /* Default value cannot be changed */
+ if (ioctl == VIDIOC_S_EXT_CTRLS ||
+ ioctl == VIDIOC_TRY_EXT_CTRLS) {
+ c->error_idx = c->count;
+ return false;
+ }
+ return true;
case V4L2_CTRL_WHICH_CUR_VAL:
return true;
case V4L2_CTRL_WHICH_REQUEST_VAL:
--
2.31.0.rc2.261.g7f71774620-goog