media: v4l2-ctrls: Fix 64bit support in get_ctrl()
PATCH 1/1 media: v4l2-ctrls: Fix 64bit support in get_ctrl()
When trying to use v4l2_ctrl_g_ctrl_int64() to retrieve a V4L2_CTRL_TYPE_INTEGER64 type value the internal helper function get_ctrl() would prematurely exits because for this control type the 'is_int' flag is not set. This would result in v4l2_ctrl_g_ctrl_int64 always returning 0.
This patch extend the condition check to allow V4L2_CTRL_TYPE_INTEGER64 type to continue processing instead of exiting.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ctrls.c +1 -1
@@ -2884,7 +2884,7 @@ static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c)* cur_to_user() calls below would need to be modified not to access * userspace memory when called from get_ctrl(). */ -if (!ctrl->is_int) +if (!ctrl->is_int && ctrl->type !=V4L2_CTRL_TYPE_INTEGER64 )return -EINVAL ;if (ctrl->flags &V4L2_CTRL_FLAG_WRITE_ONLY )
Signature · 1 line
1.8.5.1
Hi Benoit,
Quoted 19 lines · Benoit Parrot
When trying to use
v4l2_ctrl_g_ctrl_int64()to retrieve aV4L2_CTRL_TYPE_INTEGER64type value the internal helper functionget_ctrl()would prematurely exits because for this control type the 'is_int' flag is not set. This would result inv4l2_ctrl_g_ctrl_int64always returning 0.This patch extend the condition check to allow
V4L2_CTRL_TYPE_INTEGER64type to continue processing instead of exiting.Signed-off-by Benoit Parrot <[email protected]>--- drivers/media/v4l2-core/v4l2-ctrls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-ctrls.c +0
-0
drivers/media/v4l2-core/v4l2-ctrls.c static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c) · line 2890
Quoted 8 lines
drivers/media/v4l2-core/v4l2-ctrls.c +1
-1@@ -2884,7 +2884,7 @@ static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c)* cur_to_user() calls below would need to be modified not to access * userspace memory when called from get_ctrl(). */ -if (!ctrl->is_int) +if (!ctrl->is_int && ctrl->type !=V4L2_CTRL_TYPE_INTEGER64 )return -EINVAL ;if (ctrl->flags &V4L2_CTRL_FLAG_WRITE_ONLY )
Well spotted.
However, this does not appear to be the only problem with v4l2_ctrl_g_ctrl_int64(). It accesses the 32-bit value field instead of value64. While at it, could you fix that one as well?
I wonder how this could have happened. :-o
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]