[PATCH v2 10/11] staging: media: cedrus: h264: clear the DRAM buffer sizes on start
From: Jernej Skrabec
Date: Mon Nov 09 2026 - 12:57:33 EST
Above 2048 pixels, the H.264 decoder puts its deblocking and intra
prediction buffers into DRAM, and stop() frees them when their sizes
are not zero. start() only sets the sizes for wide pictures and nothing
clears them, so a narrow stream after a wide one on the same file
handle frees the buffers of the wide one again. The codec data is also
shared with the other codecs, whose data can end up in the sizes.
Clear the sizes at the start of start().
Fixes: 03e612e701a6 ("media: cedrus: Fix H264 4k support")
Signed-off-by: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
---
drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
index 97958ceee8d1..e7a3bfbc3531 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c
@@ -573,6 +573,14 @@ static int cedrus_h264_start(struct cedrus_ctx *ctx)
unsigned int pic_info_size;
int ret;
+ /*
+ * The sizes tell stop() whether the DRAM buffers below were
+ * allocated. Clear them, as they are only set for wide pictures and
+ * the codec data is shared with the other codecs.
+ */
+ ctx->codec.h264.deblk_buf_size = 0;
+ ctx->codec.h264.intra_pred_buf_size = 0;
+
/*
* NOTE: All buffers allocated here are only used by HW, so we
* can add DMA_ATTR_NO_KERNEL_MAPPING flag when allocating them.
--
2.43.0