[PATCH v2 5/7] media: rkvdec: hevc: bound predicted short-term RPS sets
From: Daniel Golle
Date: Fri Nov 20 2026 - 18:44:02 EST
A short-term reference picture set can be predicted from an earlier
set, and can then hold one entry more than that set. The control
validation allows 16 entries per set, which is also the size of the
arrays the driver calculates the sets in. A set predicted from a
16-entry set overflows them, on the stack and on the heap.
ITU-T H.265 7.4.8 limits a set to 15 entries, and the hardware table
has room for 15 entries per set as well. Skip the prediction when the
reference set has more than 15 entries, as is already done for an
invalid reference index.
Fixes: c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
Changes since v1:
- Was 4/7
- Rewrite the commit message
- No code change
drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
index 797a16517ed59..3b281c16a75ed 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-hevc-common.c
@@ -223,6 +223,8 @@ static void st_ref_pic_set_prediction(struct rkvdec_hevc_run *run, int idx,
(rps_data->abs_delta_rps_minus1 + 1); /* 7-60 */
ref_rps = &calculated_rps_st_sets[ref_rps_idx];
+ if (ref_rps->num_delta_pocs >= ARRAY_SIZE(use_delta_flag))
+ return;
for (j = 0; j <= ref_rps->num_delta_pocs; j++) {
used_by_curr_pic_flag[j] = !!(rps_data->used_by_curr_pic & (1 << j));
--
2.56.1