Commit daa87ca4 authored by Detlev Casanova's avatar Detlev Casanova Committed by Mauro Carvalho Chehab
Browse files

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: c9a59dc2 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
Reported-by: default avatarChristian Hewitt <christianshewitt@gmail.com>
Suggested-by: default avatarJonas Karlman <jonas@kwiboo.se>
Signed-off-by: default avatarDetlev Casanova <detlev.casanova@collabora.com>
Tested-by: default avatarChristian Hewitt <christianshewitt@gmail.com>
Reviewed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent bef4f4a8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);