* [PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables
@ 2026-12-01 15:29 Arun Iyengar via B4 Relay
2026-12-01 16:19 ` Philipp Zabel
0 siblings, 1 reply; 2+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-01 15:29 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Hans Verkuil
Cc: Philipp Zabel, linux-media, linux-kernel, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
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@gmail.com>
---
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@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables
2026-12-01 15:29 [PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables Arun Iyengar via B4 Relay
@ 2026-12-01 16:19 ` Philipp Zabel
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2026-12-01 16:19 UTC (permalink / raw)
To: aiyengar1990, Mauro Carvalho Chehab, Hans Verkuil
Cc: linux-media, linux-kernel
On Di, 2026-12-01 at 15:29 +0000, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> 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.
I think the DQT parser is wrong. If there is remaining len, it should
skip over it.
> Fixes: 50733b5b9102 ("media: add v4l2 JPEG helpers")
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> ---
> Host test, parser built in userspace: a DHT ending in FF C4 gives -EINVAL
> before and 0 after; a normal header parses the same.
I expect you can trigger the same -EINVAL by adding a DHT segment
header to the end of a DQT right now.
> 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;
The error here is that this tries to subtract the two bytes for the
segment length value again. Those were already subtracted at the start
of the for loop. Wouldn't
return jpeg_skip(stream, len);
be correct?
regards
Philipp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 15:29 [PATCH] media: v4l2-jpeg: do not rewind the stream after Huffman tables Arun Iyengar via B4 Relay
2026-12-01 16:19 ` Philipp Zabel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®