Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l2-ctrls: only check def for menu, integer and boolean controls

The 'def' field is only valid for menus, integers and booleans.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
02ac0480 513521ea

+8 -1
+8 -1
drivers/media/video/v4l2-ctrls.c
··· 962 962 963 963 /* Sanity checks */ 964 964 if (id == 0 || name == NULL || id >= V4L2_CID_PRIVATE_BASE || 965 - def < min || def > max || max < min || 965 + max < min || 966 966 (type == V4L2_CTRL_TYPE_INTEGER && step == 0) || 967 967 (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) || 968 968 (type == V4L2_CTRL_TYPE_STRING && max == 0)) { 969 + handler_set_err(hdl, -ERANGE); 970 + return NULL; 971 + } 972 + if ((type == V4L2_CTRL_TYPE_INTEGER || 973 + type == V4L2_CTRL_TYPE_MENU || 974 + type == V4L2_CTRL_TYPE_BOOLEAN) && 975 + (def < min || def > max)) { 969 976 handler_set_err(hdl, -ERANGE); 970 977 return NULL; 971 978 }