mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
media: v4l2-ctrls-api: fix error handling for v4l2_g_ctrl()
commit 4c76f331a9a173ac8fe1297a9231c2a38f88e368 upstream.
As detected by Coverity, the error check logic at get_ctrl() is
broken: if ptr_to_user() fails to fill a control due to an error,
no errors are returned and v4l2_g_ctrl() returns success on a
failed operation, which may cause applications to fail.
Add an error check at get_ctrl() and ensure that it will
be returned to userspace without filling the control value if
get_ctrl() fails.
Fixes: 71c689dc2e ("media: v4l2-ctrls: split up into four source files")
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c63c30c9d9
commit
f7503fd2d7
@@ -753,9 +753,10 @@ static int get_ctrl(struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c)
|
|||||||
for (i = 0; i < master->ncontrols; i++)
|
for (i = 0; i < master->ncontrols; i++)
|
||||||
cur_to_new(master->cluster[i]);
|
cur_to_new(master->cluster[i]);
|
||||||
ret = call_op(master, g_volatile_ctrl);
|
ret = call_op(master, g_volatile_ctrl);
|
||||||
new_to_user(c, ctrl);
|
if (!ret)
|
||||||
|
ret = new_to_user(c, ctrl);
|
||||||
} else {
|
} else {
|
||||||
cur_to_user(c, ctrl);
|
ret = cur_to_user(c, ctrl);
|
||||||
}
|
}
|
||||||
v4l2_ctrl_unlock(master);
|
v4l2_ctrl_unlock(master);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -770,7 +771,10 @@ int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *control)
|
|||||||
if (!ctrl || !ctrl->is_int)
|
if (!ctrl || !ctrl->is_int)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
ret = get_ctrl(ctrl, &c);
|
ret = get_ctrl(ctrl, &c);
|
||||||
control->value = c.value;
|
|
||||||
|
if (!ret)
|
||||||
|
control->value = c.value;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(v4l2_g_ctrl);
|
EXPORT_SYMBOL(v4l2_g_ctrl);
|
||||||
@@ -811,10 +815,11 @@ static int set_ctrl_lock(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
v4l2_ctrl_lock(ctrl);
|
v4l2_ctrl_lock(ctrl);
|
||||||
user_to_new(c, ctrl);
|
ret = user_to_new(c, ctrl);
|
||||||
ret = set_ctrl(fh, ctrl, 0);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
cur_to_user(c, ctrl);
|
ret = set_ctrl(fh, ctrl, 0);
|
||||||
|
if (!ret)
|
||||||
|
ret = cur_to_user(c, ctrl);
|
||||||
v4l2_ctrl_unlock(ctrl);
|
v4l2_ctrl_unlock(ctrl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user