media: rkvdec: Improve handling missing short/long term RPS
Subsystems (3)
Detlev Casanova
maintainerPATCH 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.
--- 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
@@ -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
Quoted 6 lines · Detlev Casanova
The values of
ext_sps_st_rpsandext_sps_lt_rpsin structrkvdec_hevc_runare 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_preamblefunction 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")Reported-by Christian Hewitt <[email protected]>Suggested-by Jonas Karlman <[email protected]>Signed-off-by Detlev Casanova <[email protected]>
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@@ -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
Le vendredi 23 janvier 2026 à 14:22 -0500, Detlev Casanova a écrit :
Quoted 11 lines
The values of
ext_sps_st_rpsandext_sps_lt_rpsin structrkvdec_hevc_runare 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_preamblefunction 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")Reported-by Christian Hewitt <[email protected]>Suggested-by Jonas Karlman <[email protected]>Signed-off-by Detlev Casanova <[email protected]>
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@@ -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);