aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-09-30 17:28:42 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-10-21 06:53:27 -0400
commitc601f53f8fe5aab4d8b506104d0fd0a7b6a19922 (patch)
tree7f55147e7456f864f941ccbd89d6be897f544850 /drivers/media
parentc204e1fafbd50a158a34c8a5bd9682cb04ecb29b (diff)
[media] v4l: uvcvideo: Fix buffer completion size check
Commit e93e7fd9f5a3fffec7792dbcc4c3574653effda7 ("v4l2: uvcvideo: Allow using larger buffers") reworked the buffer size sanity check at buffer completion time to use the frame size instead of the allocated buffer size. However, it introduced two bugs in doing so: - it assigned the allocated buffer size to the frame_size field, instead of assigning the correct frame size - it performed the assignment in the S_FMT handler, resulting in the frame_size field being uninitialized if the userspace application doesn't call S_FMT. Fix both issues by removing the frame_size field and validating the buffer size against the UVC video control dwMaxFrameSize. Fixes: e93e7fd9f5a3 ("v4l2: uvcvideo: Allow using larger buffers") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c1
-rw-r--r--drivers/media/usb/uvc/uvc_video.c2
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h1
3 files changed, 1 insertions, 3 deletions
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 60a8e2c3631e..378ae02e593b 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -318,7 +318,6 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
318 stream->ctrl = probe; 318 stream->ctrl = probe;
319 stream->cur_format = format; 319 stream->cur_format = format;
320 stream->cur_frame = frame; 320 stream->cur_frame = frame;
321 stream->frame_size = fmt->fmt.pix.sizeimage;
322 321
323done: 322done:
324 mutex_unlock(&stream->mutex); 323 mutex_unlock(&stream->mutex);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 9ace520bb079..df81b9c4faf1 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1143,7 +1143,7 @@ static int uvc_video_encode_data(struct uvc_streaming *stream,
1143static void uvc_video_validate_buffer(const struct uvc_streaming *stream, 1143static void uvc_video_validate_buffer(const struct uvc_streaming *stream,
1144 struct uvc_buffer *buf) 1144 struct uvc_buffer *buf)
1145{ 1145{
1146 if (stream->frame_size != buf->bytesused && 1146 if (stream->ctrl.dwMaxVideoFrameSize != buf->bytesused &&
1147 !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED)) 1147 !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED))
1148 buf->error = 1; 1148 buf->error = 1;
1149} 1149}
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 6f676c29ec09..864ada740360 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -457,7 +457,6 @@ struct uvc_streaming {
457 struct uvc_format *def_format; 457 struct uvc_format *def_format;
458 struct uvc_format *cur_format; 458 struct uvc_format *cur_format;
459 struct uvc_frame *cur_frame; 459 struct uvc_frame *cur_frame;
460 size_t frame_size;
461 460
462 /* Protect access to ctrl, cur_format, cur_frame and hardware video 461 /* Protect access to ctrl, cur_format, cur_frame and hardware video
463 * probe control. 462 * probe control.