Skip to contentSkip to conversation

media: rkvdec: Improve handling missing short/long term RPS

PATCH In review Detlev Casanova 3 participants 3 messages Jan 23 – Feb 6

Subsystems (3)
lore
Share & tools
lore

Detlev Casanova

author maintainer
#0 lore raw

PATCH 1/1 media: rkvdec: Improve handling missing short/long term RPS

The values of ext_sps_st_rps and ext_sps_lt_rps in struct rkvdec_hevc_run are not initialized when the respective controls are not set by userspace.

When this is the case, set them to NULL so the rkvdec_hevc_run_preamble function that parses controls does not access garbage data which leads to a panic on unaccessible memory.

Fixes c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
---
 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +4 -0
index 28267ee30190..3119f3bc9f98 100644
@@ -500,11 +500,15 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx,
 		ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
 				      V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS);
 		run->ext_sps_st_rps = ctrl ? ctrl->p_cur.p : NULL;
+	} else {
+		run->ext_sps_st_rps = NULL;
 	}
 	if (ctx->has_sps_lt_rps) {
 		ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
 				      V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS);
 		run->ext_sps_lt_rps = ctrl ? ctrl->p_cur.p : NULL;
+	} else {
+		run->ext_sps_lt_rps = NULL;
 	}
 
 	rkvdec_run_preamble(ctx, &run->base);
Signature · 1 line
2.52.0
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Detlev Casanova

The values of ext_sps_st_rps and ext_sps_lt_rps in struct rkvdec_hevc_run are not initialized when the respective controls are not set by userspace.

Quoted 8 lines

When this is the case, set them to NULL so the rkvdec_hevc_run_preamble function that parses controls does not access garbage data which leads to a panic on unaccessible memory.

Fixes c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")

This solves the sps/rps warnings and occasional kernel splats I’ve been seeing with some HEVC media. Thanks!

Quoted 27 lines

---
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c | 4 ++++

1 file changed, 4 insertions(+)
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +4 -1
index 28267ee30190..3119f3bc9f98 100644
@@ -500,11 +500,15 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx,
       ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
                     V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS);
       run->ext_sps_st_rps = ctrl ? ctrl->p_cur.p : NULL;
+    } else {
+        run->ext_sps_st_rps = NULL;
   }
   if (ctx->has_sps_lt_rps) {
       ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
                     V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS);
       run->ext_sps_lt_rps = ctrl ? ctrl->p_cur.p : NULL;
+    } else {
+        run->ext_sps_lt_rps = NULL;
   }
 
   rkvdec_run_preamble(ctx, &run->base);
--

2.52.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Detlev Casanova

Le vendredi 23 janvier 2026 à 14:22 -0500, Detlev Casanova a écrit :

Quoted 11 lines

The values of ext_sps_st_rps and ext_sps_lt_rps in struct rkvdec_hevc_run are not initialized when the respective controls are not set by userspace.

When this is the case, set them to NULL so the rkvdec_hevc_run_preamble function that parses controls does not access garbage data which leads to a panic on unaccessible memory.

Fixes c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")

I'll pick this in fixes, so we don't release 6.20 (or 7) with that bug.

cheers,
Nicolas

Quoted 24 lines

---
 drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c | 4 ++++

 1 file changed, 4 insertions(+)
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c +4 -0
index 28267ee30190..3119f3bc9f98 100644
@@ -500,11 +500,15 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx,
  		ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
  				      V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS);
  		run->ext_sps_st_rps = ctrl ? ctrl->p_cur.p : NULL;
+	} else {
+		run->ext_sps_st_rps = NULL;
  	}
  	if (ctx->has_sps_lt_rps) {
  		ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
  				      V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS);
  		run->ext_sps_lt_rps = ctrl ? ctrl->p_cur.p : NULL;
+	} else {
+		run->ext_sps_lt_rps = NULL;
  	}


  rkvdec_run_preamble(ctx, &run->base);