[media] v4l2-ctrls: return elem_size instead of strlen
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 18 Jan 2014 09:06:01 +0000 (06:06 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Thu, 17 Jul 2014 14:57:20 +0000 (11:57 -0300)
When getting a string and the size given by the application is too
short return the max length the string can have (elem_size) instead
of the string length + 1. That makes more sense.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-ctrls.c

index b3ab8a974afaa1895409a7f1247564e774fe88aa..e6e33b3110fa017552c9373f0b66a7aaf99ff120 100644 (file)
@@ -1332,7 +1332,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
        case V4L2_CTRL_TYPE_STRING:
                len = strlen(ptr.p_char);
                if (c->size < len + 1) {
-                       c->size = len + 1;
+                       c->size = ctrl->elem_size;
                        return -ENOSPC;
                }
                return copy_to_user(c->string, ptr.p_char, len + 1) ?