[PATCH v5 0/2] media: uvcvideo: Fixes for frame sequence number

From: Ricardo Ribalda

Date: Mon Mar 23 2026 - 05:54:32 EST


This series fixes a couple of corner cases where the frame sequence
number is not properly handled.

Please note that the first patch has not been tested in a camera
without EOF. To emulate it I have used this:

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index b66d701f2582d..097bed2f7845f 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1360,6 +1360,8 @@ static void uvc_video_decode_end(struct uvc_streaming *stream,
{
/* Mark the buffer as done if the EOF marker is set. */
if (data[1] & UVC_STREAM_EOF && buf->bytesused != 0) {
+ printk(KERN_ERR "Ignoring EOF\n");
+ return;
uvc_dbg(stream->dev, FRAME, "Frame complete (EOF found)\n");
if (data[0] == len)
uvc_dbg(stream->dev, FRAME, "EOF in empty payload\n");

Signed-off-by: Ricardo Ribalda <ribalda@xxxxxxxxxxxx>
---
Changes in v5 (Thanks Hans):
- Swap order of patches
- Remove duplicated conditions.
- Link to v4: https://lore.kernel.org/r/20260320-uvc-fid-v4-0-f24f168ca2f9@xxxxxxxxxxxx

Changes in v4 (Thanks Hans):
- Fix 2/2 logic.
- Link to v3: https://lore.kernel.org/r/20260316-uvc-fid-v3-0-c793354469b5@xxxxxxxxxxxx

Changes in v3:
- Fix typo in commit message.
- Add new patch
- Link to v2: https://lore.kernel.org/r/20260313-uvc-fid-v2-1-3f7a996d9047@xxxxxxxxxxxx

Changes in v2 (Thanks Laurent):
- Improve commit message.
- Remove original timestamp and sequence assignment. It is not neeed
- Link to v1: https://lore.kernel.org/r/20260310-uvc-fid-v1-1-5e37dc3c7024@xxxxxxxxxxxx

---
Ricardo Ribalda (2):
media: uvcvideo: Fix sequence number when no EOF
media: uvcvideo: Fix buffer sequence in frame gaps

drivers/media/usb/uvc/uvc_video.c | 110 +++++++++++++++++++++-----------------
1 file changed, 61 insertions(+), 49 deletions(-)
---
base-commit: a7da7fb57f2a787412da1a62292a17fa00fbfbdf
change-id: 20260310-uvc-fid-e1e55447b6f1

Best regards,
--
Ricardo Ribalda <ribalda@xxxxxxxxxxxx>