Re: [PATCH 3/7] media: rkvdec: hevc: bound the RPS reads by the control size
From: Daniel Golle
Date: Fri Nov 20 2026 - 18:23:31 EST
Hi again,
I missed the part of your review which was inlined with the code.
See my reply below.
On Mon, Nov 16, 2026 at 08:49:44AM -0500, Nicolas Dufresne wrote:
> [...]
> > --- a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
> > +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
> > @@ -448,18 +448,18 @@ void rkvdec_hevc_run_preamble(struct rkvdec_ctx *ctx,
> > V4L2_CID_STATELESS_HEVC_SCALING_MATRIX);
> > run->scaling_matrix = ctrl ? ctrl->p_cur.p : NULL;
> >
> > + run->ext_sps_st_rps = NULL;
> > if (ctx->has_sps_st_rps) {
> > 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 (ctrl && ctrl->elems >= run->sps->num_short_term_ref_pic_sets)
> > + run->ext_sps_st_rps = ctrl->p_cur.p;
> > }
> > + run->ext_sps_lt_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;
> > + if (ctrl && ctrl->elems >= run->sps->num_long_term_ref_pics_sps)
> > + run->ext_sps_lt_rps = ctrl->p_cur.p;
>
> So you are saying that if the passed array is too short, we should use an older
> entry to none? That seems a little strange, what about up-front rejecting bad
> entries?
That's what I do, but only after patch 5, before that the decoder would
still run with the previous table. I will reorder the series so the
refusal comes first.
Rejecting when the control is set does not work, as the count and the
array are separate controls which can be set in any order, also in
different requests. The first point where both are known is when the
request is applied in device_run.