Skip to contentSkip to conversation

media: v4l2-ctrls: Fix 64bit support in get_ctrl()

PATCH In review Benoit Parrot 2 participants 2 messages Sep 21, 2015 – Sep 22, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.
Also v4l2_ctrl_g_ctrl_int64() is reading and returning the 32bit value member instead of the 64bit version, so fixing that as well.

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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +3 -3
index b6b7dcc1b77d..6f1a8a6cc149 100644
@@ -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)
@@ -2942,9 +2942,9 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl)
 
 	/* It's a driver bug if this happens. */
 	WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64);
-	c.value = 0;
+	c.value64 = 0;
 	get_ctrl(ctrl, &c);
-	return c.value;
+	return c.value64;
 }
 EXPORT_SYMBOL(v4l2_ctrl_g_ctrl_int64);
 
Signature · 1 line
1.8.5.1
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Benoit Parrot

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.
Also v4l2_ctrl_g_ctrl_int64() is reading and returning the 32bit value member instead of the 64bit version, so fixing that as well.

Quoted 4 lines

This patch extend the condition check to allow V4L2_CTRL_TYPE_INTEGER64 type to continue processing instead of exiting.

Thanks!

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]