[PATCH v4 04/17] media: v4l2-ctrls: validate AV1 context_update_tile_id
From: Sofus Forstreuter
Date: Sat Nov 28 2026 - 17:03:08 EST
Increase V4L2_AV1_MAX_TILE_COUNT to MAX_TILE_COLS * MAX_TILE_ROWS
Reviewed-by: Neal Gompa <neal@xxxxxxxxx>
Signed-off-by: Sofus Forstreuter <sofus.c@xxxxxxxxxx>
---
Cc: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
Cc: Xiaoyong Lu <xiaoyong.lu@xxxxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-ctrls-core.c | 9 +++++++++
include/uapi/linux/v4l2-controls.h | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
index 12a799824c44..6ded78ef7b0f 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -114,6 +114,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,
struct v4l2_ctrl_vp9_frame *p_vp9_frame;
struct v4l2_ctrl_fwht_params *p_fwht_params;
struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
+ struct v4l2_ctrl_av1_frame *p_av1_frame;
struct v4l2_ctrl_av1_sequence *p_av1_sequence;
struct v4l2_ctrl_hevc_sps *p_hevc_sps;
void *p = ptr.p + idx * ctrl->elem_size;
@@ -162,6 +163,11 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,
p_vp9_frame->flags |= V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING |
V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING;
break;
+ case V4L2_CTRL_TYPE_AV1_FRAME:
+ p_av1_frame = p;
+ p_av1_frame->tile_info.tile_cols = 1;
+ p_av1_frame->tile_info.tile_rows = 1;
+ break;
case V4L2_CTRL_TYPE_AV1_SEQUENCE:
p_av1_sequence = p;
/*
@@ -814,6 +820,9 @@ static int validate_av1_tile_info(struct v4l2_av1_tile_info *t)
if ((u32)t->tile_cols * t->tile_rows > V4L2_AV1_MAX_TILE_COUNT)
return -EINVAL;
+ if (t->context_update_tile_id >= t->tile_cols * t->tile_rows)
+ return -EINVAL;
+
return 0;
}
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index d17e41d51d2e..abdfa102a77b 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -2939,7 +2939,7 @@ struct v4l2_ctrl_vp9_compressed_hdr {
#define V4L2_AV1_MAX_NUM_PLANES 3
#define V4L2_AV1_MAX_TILE_COLS 64
#define V4L2_AV1_MAX_TILE_ROWS 64
-#define V4L2_AV1_MAX_TILE_COUNT 512
+#define V4L2_AV1_MAX_TILE_COUNT 4096
#define V4L2_AV1_SEQUENCE_FLAG_STILL_PICTURE 0x00000001
#define V4L2_AV1_SEQUENCE_FLAG_USE_128X128_SUPERBLOCK 0x00000002
--
2.56.0