From dda6a76b54e48c660ec4a47f34f4abbc141ad591 Mon Sep 17 00:00:00 2001 From: "Chan, Roy" Date: Mon, 11 Aug 2025 21:08:52 -0400 Subject: [PATCH] amd/vpelib: check stream_count as well before accessing streams [WHY] It was found that the caller may call with stream_count = 0, while streams array is some garbage. it randomly ends up output_ctx being modified and leading to validation failure. [HOW] Add checking to the stream_count. Acked-by: Chuanyu Tseng Signed-off-by: Roy Chan Part-of: --- src/amd/vpelib/src/core/geometric_scaling.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amd/vpelib/src/core/geometric_scaling.c b/src/amd/vpelib/src/core/geometric_scaling.c index 57a2c019f78..975ce51818f 100644 --- a/src/amd/vpelib/src/core/geometric_scaling.c +++ b/src/amd/vpelib/src/core/geometric_scaling.c @@ -38,7 +38,8 @@ void vpe_geometric_scaling_feature_skip( struct vpe_priv *vpe_priv, const struct vpe_build_param *param) { - if (param->streams && param->streams->flags.geometric_scaling) { + if ((param->num_streams > 0) && (param->streams != NULL) && + (param->streams->flags.geometric_scaling != 0)) { /* copy input cs to output for skiping gamut and gamma conversion */ vpe_priv->output_ctx.surface.cs.primaries = param->streams[0].surface_info.cs.primaries; vpe_priv->output_ctx.surface.cs.tf = param->streams[0].surface_info.cs.tf; @@ -52,7 +53,6 @@ void vpe_geometric_scaling_feature_skip( /* disable blending */ vpe_priv->stream_ctx[0].stream.blend_info.blending = false; } - } /*