Skip to content

Commit bda2859

Browse files
ribaldahverkuil
authored andcommitted
media: uvcvideo: Do not mark valid metadata as invalid
Currently, the driver performs a length check of the metadata buffer before the actual metadata size is known and before the metadata is decided to be copied. This results in valid metadata buffers being incorrectly marked as invalid. Move the length check to occur after the metadata size is determined and is decided to be copied. Cc: [email protected] Fixes: 088ead2 ("media: uvcvideo: Add a metadata device node") Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 2acded8 commit bda2859

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/media/usb/uvc/uvc_video.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,12 +1442,6 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
14421442
if (!meta_buf || length == 2)
14431443
return;
14441444

1445-
if (meta_buf->length - meta_buf->bytesused <
1446-
length + sizeof(meta->ns) + sizeof(meta->sof)) {
1447-
meta_buf->error = 1;
1448-
return;
1449-
}
1450-
14511445
has_pts = mem[1] & UVC_STREAM_PTS;
14521446
has_scr = mem[1] & UVC_STREAM_SCR;
14531447

@@ -1468,6 +1462,12 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
14681462
!memcmp(scr, stream->clock.last_scr, 6)))
14691463
return;
14701464

1465+
if (meta_buf->length - meta_buf->bytesused <
1466+
length + sizeof(meta->ns) + sizeof(meta->sof)) {
1467+
meta_buf->error = 1;
1468+
return;
1469+
}
1470+
14711471
meta = (struct uvc_meta_buf *)((u8 *)meta_buf->mem + meta_buf->bytesused);
14721472
local_irq_save(flags);
14731473
time = uvc_video_get_time();

0 commit comments

Comments
 (0)