mirror of https://gitee.com/openkylin/linux.git
[media] v4l2-ctrl: fix error return of copy_to/from_user
copy_to/from_user returns the number of bytes not copied, it does not return a 'normal' linux error code. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
c336f75e1e
commit
40265bbe42
|
@ -1326,7 +1326,8 @@ static int ptr_to_user(struct v4l2_ext_control *c,
|
||||||
u32 len;
|
u32 len;
|
||||||
|
|
||||||
if (ctrl->is_ptr && !ctrl->is_string)
|
if (ctrl->is_ptr && !ctrl->is_string)
|
||||||
return copy_to_user(c->ptr, ptr.p, c->size);
|
return copy_to_user(c->ptr, ptr.p, c->size) ?
|
||||||
|
-EFAULT : 0;
|
||||||
|
|
||||||
switch (ctrl->type) {
|
switch (ctrl->type) {
|
||||||
case V4L2_CTRL_TYPE_STRING:
|
case V4L2_CTRL_TYPE_STRING:
|
||||||
|
@ -1336,7 +1337,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
return copy_to_user(c->string, ptr.p_char, len + 1) ?
|
return copy_to_user(c->string, ptr.p_char, len + 1) ?
|
||||||
-EFAULT : 0;
|
-EFAULT : 0;
|
||||||
case V4L2_CTRL_TYPE_INTEGER64:
|
case V4L2_CTRL_TYPE_INTEGER64:
|
||||||
c->value64 = *ptr.p_s64;
|
c->value64 = *ptr.p_s64;
|
||||||
break;
|
break;
|
||||||
|
@ -1373,7 +1374,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
|
||||||
if (ctrl->is_ptr && !ctrl->is_string) {
|
if (ctrl->is_ptr && !ctrl->is_string) {
|
||||||
unsigned idx;
|
unsigned idx;
|
||||||
|
|
||||||
ret = copy_from_user(ptr.p, c->ptr, c->size);
|
ret = copy_from_user(ptr.p, c->ptr, c->size) ? -EFAULT : 0;
|
||||||
if (ret || !ctrl->is_array)
|
if (ret || !ctrl->is_array)
|
||||||
return ret;
|
return ret;
|
||||||
for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++)
|
for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++)
|
||||||
|
@ -1391,7 +1392,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
if (size > ctrl->maximum + 1)
|
if (size > ctrl->maximum + 1)
|
||||||
size = ctrl->maximum + 1;
|
size = ctrl->maximum + 1;
|
||||||
ret = copy_from_user(ptr.p_char, c->string, size);
|
ret = copy_from_user(ptr.p_char, c->string, size) ? -EFAULT : 0;
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
char last = ptr.p_char[size - 1];
|
char last = ptr.p_char[size - 1];
|
||||||
|
|
||||||
|
@ -1401,7 +1402,7 @@ static int user_to_ptr(struct v4l2_ext_control *c,
|
||||||
if (strlen(ptr.p_char) == ctrl->maximum && last)
|
if (strlen(ptr.p_char) == ctrl->maximum && last)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
return ret ? -EFAULT : 0;
|
return ret;
|
||||||
default:
|
default:
|
||||||
*ptr.p_s32 = c->value;
|
*ptr.p_s32 = c->value;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue