[PATCH v2 3/6] media: uvcvideo: Use bHeaderLength for payload size in stats
From: Ricardo Ribalda
Date: Mon Nov 16 2026 - 12:52:49 EST
uvc_video_stats_decode() does not take into consideration extended
header data (e.g. MSXU metadata) when it calculates the payload size or
decides if a UVC packet contains payload data or not.
Use the correct size (data[0]) instead of the minimum header size.
Fixes: 7bc5edb00bbd ("[media] uvcvideo: Extract video stream statistics")
Fixes: 25738cbd72db ("[media] uvcvideo: Extract timestamp-related statistics")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
drivers/media/usb/uvc/uvc_video.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 8bae91af03ba..ac8e0c3a0c71 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1016,9 +1016,9 @@ static void uvc_video_stats_decode(struct uvc_streaming *stream,
* their first empty packet ?
*/
if (stream->stats.frame.size == 0) {
- if (len > header_size)
+ if (len > data[0])
stream->stats.frame.has_initial_pts = has_pts;
- if (len == header_size && has_pts)
+ if (len == data[0] && has_pts)
stream->stats.frame.has_early_pts = true;
}
@@ -1047,15 +1047,15 @@ static void uvc_video_stats_decode(struct uvc_streaming *stream,
}
/* Record the first non-empty packet number. */
- if (stream->stats.frame.size == 0 && len > header_size)
+ if (stream->stats.frame.size == 0 && len > data[0])
stream->stats.frame.first_data = stream->stats.frame.nb_packets;
/* Update the frame size. */
- stream->stats.frame.size += len - header_size;
+ stream->stats.frame.size += len - data[0];
/* Update the packets counters. */
stream->stats.frame.nb_packets++;
- if (len <= header_size)
+ if (len <= data[0])
stream->stats.frame.nb_empty++;
if (data[1] & UVC_STREAM_ERR)
--
2.56.0.679.gc527c65306-goog