From cecfe9b8a511ec0c9df456770abf547444c87de6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 25 Sep 2017 06:41:02 -0300 Subject: [PATCH] [media] v4l2-ctrls.c: allow empty control handlers If you have a control handler that does not contain any controls, then currently calling VIDIOC_G/S/TRY_EXT_CTRLS with count == 0 will return -EINVAL in the class_check() function. This is not correct, there is no reason why this should return an error. The purpose of setting count to 0 is to test if the ioctl can mix controls from different control classes. And this is possible. The fact that there are not actually any controls defined is another matter that is unrelated to this test. This caused v4l2-compliance to fail, so that is fixed with this patch applied. Signed-off-by: Hans Verkuil Reported-by: Dave Stevenson Tested-by: Dave Stevenson Acked-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-ctrls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index dd1db678718c..4e53a8654690 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -2818,7 +2818,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, static int class_check(struct v4l2_ctrl_handler *hdl, u32 which) { if (which == 0 || which == V4L2_CTRL_WHICH_DEF_VAL) - return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0; + return 0; return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; } -- 2.11.0