media: uvcvideo: Do not mark valid metadata as invalid
commit bda2859bff0b9596a19648f3740c697ce4c71496 upstream.
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: stable@vger.kernel.org
Fixes: 088ead2552 ("media: uvcvideo: Add a metadata device node")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20250707-uvc-meta-v8-1-ed17f8b1218b@chromium.org
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1e269581b3
commit
2a0fc8fc58
@@ -1309,12 +1309,6 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
|
||||
if (!meta_buf || length == 2)
|
||||
return;
|
||||
|
||||
if (meta_buf->length - meta_buf->bytesused <
|
||||
length + sizeof(meta->ns) + sizeof(meta->sof)) {
|
||||
meta_buf->error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
has_pts = mem[1] & UVC_STREAM_PTS;
|
||||
has_scr = mem[1] & UVC_STREAM_SCR;
|
||||
|
||||
@@ -1335,6 +1329,12 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
|
||||
!memcmp(scr, stream->clock.last_scr, 6)))
|
||||
return;
|
||||
|
||||
if (meta_buf->length - meta_buf->bytesused <
|
||||
length + sizeof(meta->ns) + sizeof(meta->sof)) {
|
||||
meta_buf->error = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
meta = (struct uvc_meta_buf *)((u8 *)meta_buf->mem + meta_buf->bytesused);
|
||||
local_irq_save(flags);
|
||||
time = uvc_video_get_time();
|
||||
|
||||
Reference in New Issue
Block a user