diff options
author | Xi Wang <xi.wang@gmail.com> | 2012-04-06 08:32:36 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-04-18 10:09:03 -0400 |
commit | 5f0049bd69b96537dc7c02755c169fb4ccca3ddf (patch) | |
tree | 3fb163d8fa818edd1eaf4cfa2688c427494f9d46 /drivers/media | |
parent | 30059d93b07a034555defbf14d689a279fd7368d (diff) |
[media] v4l2-ctrls: fix integer overflow in v4l2_g_ext_ctrls()
A large cs->count from userspace may overflow the allocation size,
leading to memory corruption. v4l2_g_ext_ctrls() can be reached
from subdev_do_ioctl() or __video_do_ioctl().
Use kmalloc_array() to avoid the overflow.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 3e0a72dec994..bf62b105b49d 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c | |||
@@ -2036,7 +2036,8 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs | |||
2036 | return class_check(hdl, cs->ctrl_class); | 2036 | return class_check(hdl, cs->ctrl_class); |
2037 | 2037 | ||
2038 | if (cs->count > ARRAY_SIZE(helper)) { | 2038 | if (cs->count > ARRAY_SIZE(helper)) { |
2039 | helpers = kmalloc(sizeof(helper[0]) * cs->count, GFP_KERNEL); | 2039 | helpers = kmalloc_array(cs->count, sizeof(helper[0]), |
2040 | GFP_KERNEL); | ||
2040 | if (helpers == NULL) | 2041 | if (helpers == NULL) |
2041 | return -ENOMEM; | 2042 | return -ENOMEM; |
2042 | } | 2043 | } |