From c336f75e1e822658122b96d874da01f5f4df994d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 18 Jan 2014 06:06:01 -0300 Subject: [PATCH] [media] v4l2-ctrls: return elem_size instead of strlen 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 Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-ctrls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b3ab8a974afa..e6e33b3110fa 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -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) ? -- 2.20.1