diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-29 14:27:05 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-30 08:02:18 -0200 |
commit | 02ac04805e6a753610d7dd1716181ccbd8e366af (patch) | |
tree | 84333bc8469a497aee775457837e1dc86509c550 /drivers/media/video | |
parent | [media] v4l2-ctrls: use const char * const * for the menu arrays (diff) | |
download | linux-dev-02ac04805e6a753610d7dd1716181ccbd8e366af.tar.xz linux-dev-02ac04805e6a753610d7dd1716181ccbd8e366af.zip |
[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>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 6c0fadc2beab..8f81efcfcf56 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -962,13 +962,20 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, /* Sanity checks */ if (id == 0 || name == NULL || id >= V4L2_CID_PRIVATE_BASE || - def < min || def > max || max < min || + max < min || (type == V4L2_CTRL_TYPE_INTEGER && step == 0) || (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) || (type == V4L2_CTRL_TYPE_STRING && max == 0)) { handler_set_err(hdl, -ERANGE); return NULL; } + if ((type == V4L2_CTRL_TYPE_INTEGER || + type == V4L2_CTRL_TYPE_MENU || + type == V4L2_CTRL_TYPE_BOOLEAN) && + (def < min || def > max)) { + handler_set_err(hdl, -ERANGE); + return NULL; + } if (type == V4L2_CTRL_TYPE_BUTTON) flags |= V4L2_CTRL_FLAG_WRITE_ONLY; |