diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-10-02 01:47:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-10-07 09:19:34 -0400 |
commit | 1b8b10cc7e6bd9bf017c58e32b1e7f632e23850d (patch) | |
tree | f5e97c8bbf2bbc0797088f08d34c6f9cd795f202 /drivers/media/v4l2-core | |
parent | 8a18382c3196978164f0f6290aac98f2f6f43c00 (diff) |
[media] v4l2-ioctl: add blocks check for VIDIOC_SUBDEV_G/S_EDID
The maximum size of an EDID is 32768 bytes, which is 32768 / 128 = 256 blocks.
Return -EINVAL if blocks > 256 to ensure that the memory allocation is sane.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 16205d9bddfc..11874c170cbe 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -2212,6 +2212,10 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, | |||
2212 | struct v4l2_subdev_edid *edid = parg; | 2212 | struct v4l2_subdev_edid *edid = parg; |
2213 | 2213 | ||
2214 | if (edid->blocks) { | 2214 | if (edid->blocks) { |
2215 | if (edid->blocks > 256) { | ||
2216 | ret = -EINVAL; | ||
2217 | break; | ||
2218 | } | ||
2215 | *user_ptr = (void __user *)edid->edid; | 2219 | *user_ptr = (void __user *)edid->edid; |
2216 | *kernel_ptr = (void *)&edid->edid; | 2220 | *kernel_ptr = (void *)&edid->edid; |
2217 | *array_size = edid->blocks * 128; | 2221 | *array_size = edid->blocks * 128; |