[PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables

From: Arun Iyengar via B4 Relay

Date: Tue Dec 01 2026 - 10:29:32 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

After the table loop len is normally 0, so jpeg_skip(stream, len - 2)
moves the stream back two bytes and the next marker search rescans the
end of the last table. Return 0, as the quantization table parser does.

Fixes: 50733b5b9102 ("media: add v4l2 JPEG helpers")
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
Host test, parser built in userspace: a DHT ending in FF C4 gives -EINVAL
before and 0 after; a normal header parses the same.
arm64 allmodconfig W=1 build is clean. Not run on coda hardware.

Developed with Claude (Anthropic) as a coding assistant, which wrote the
code and this message. I reviewed it.
---
drivers/media/v4l2-core/v4l2-jpeg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-core/v4l2-jpeg.c
index 36a0f1a1b0d9..8b80f4b5311b 100644
--- a/drivers/media/v4l2-core/v4l2-jpeg.c
+++ b/drivers/media/v4l2-core/v4l2-jpeg.c
@@ -525,7 +525,7 @@ static int jpeg_parse_huffman_tables(struct jpeg_stream *stream,
}
}

- return jpeg_skip(stream, len - 2);
+ return 0;
}

/* B.2.4.4 Restart interval definition syntax */

---
base-commit: 95c189b26efb07257888ccf9d873a5c366aafbc6
change-id: 20261201-v4l2-jpeg-dht-rewind-7b1b800d9ace

Best regards,
--
Arun Iyengar <aiyengar1990@xxxxxxxxx>