diff options
| author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-11-09 16:28:14 -0500 |
|---|---|---|
| committer | Ben Hutchings <ben@decadent.org.uk> | 2018-06-01 00:30:04 +0100 |
| commit | 8a95224d7ef3818fb367acc4a6cbdfb30229a8a7 (patch) | |
| tree | 9662b58257134c412e92791ec4ae1fdb5eb7ed6b /drivers/media | |
| parent | 03e58a520044e3ea80a3ea43586f956e2e86c74d (diff) | |
media: cpia2: Fix a couple off by one bugs
commit d5ac225c7d64c9c3ef821239edc035634e594ec9 upstream.
The cam->buffers[] array has cam->num_frames elements so the > needs to
be changed to >= to avoid going beyond the end of the array. The
->buffers[] array is allocated in cpia2_allocate_buffers() if you want
to confirm.
Fixes: ab33d5071de7 ("V4L/DVB (3376): Add cpia2 camera support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/media')
| -rw-r--r-- | drivers/media/video/cpia2/cpia2_v4l.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 077eb1db80a1..4c6777ff7a5f 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c @@ -1152,7 +1152,7 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) struct camera_data *cam = video_drvdata(file); if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; @@ -1201,7 +1201,7 @@ static int cpia2_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->memory != V4L2_MEMORY_MMAP || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; DBG("QBUF #%d\n", buf->index); |
