[PATCH] media: rkvdec: vdpu383: Fix off-by-one in DPB POC setup

Lin Huiyi xinghui79 at qq.com
Mon Nov 30 00:28:31 PST 2026


The REF_PIC_POC() and REF_IS_VALID() bitwriter fields only describe 15
entries (i: 0-14), with RESERVED3/RESERVED4 occupying the position a
16th entry would take. The reference address loop in the same function
already uses ARRAY_SIZE(dpb) - 1 for exactly this reason.

Commit 4ae45bf4663e ("media: rkvdec: vdpu383: Drop bitfields for the
bitwriter") replaced the hand-written 15 assignments with a loop over
the full 16-element dpb array. With 16 active DPB entries, the extra
iteration writes the 16th POC and valid flag into the reserved fields,
which the old code left zeroed.

Limit the loop to 15 entries to match the field definitions and the
hardware's reference address programming.

Fixes: 4ae45bf4663e ("media: rkvdec: vdpu383: Drop bitfields for the bitwriter")
Signed-off-by: Lin Huiyi <xinghui79 at qq.com>
---
 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
index 3462d995d4..6a8ea5b193 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu383-hevc.c
@@ -313,7 +313,7 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
 	// Setup POC information
 	rkvdec_set_bw_field(hw_ps->info, CURRENT_POC, dec_params->pic_order_cnt_val);
 
-	for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) {
+	for (i = 0; i < ARRAY_SIZE(dec_params->dpb) - 1; i++) {
 		rkvdec_set_bw_field(hw_ps->info, REF_IS_VALID(i),
 				    !!(dec_params->num_active_dpb_entries > i));
 		rkvdec_set_bw_field(hw_ps->info, REF_PIC_POC(i),
-- 
2.56.1




More information about the Linux-rockchip mailing list