From 387a1c2c08d8d6d8a5a1c4e4e5c31238e204f5d5 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 26 Aug 2025 08:05:32 +0200 Subject: [PATCH] radv: fix hashing graphics pipeline when no stages are compiled It's possible with GPL. This fixes a NULL pointer dereference with updated pipeline binaries tests in VKCTS. Cc: mesa-stable Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit 944e26eae771d75a8f59b21294e30d27a15f916c) --- .pick_status.json | 2 +- src/amd/vulkan/radv_pipeline_graphics.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a3bd014759a..ae5f909e0a1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4434,7 +4434,7 @@ "description": "radv: fix hashing graphics pipeline when no stages are compiled", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index eb02c7bcdb9..56c82481da3 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2953,14 +2953,16 @@ radv_graphics_pipeline_hash(const struct radv_device *device, const struct radv_ _mesa_sha1_update(&ctx, &gfx_state->key.gfx_state, sizeof(gfx_state->key.gfx_state)); - for (unsigned s = 0; s < MESA_VULKAN_SHADER_STAGES; s++) { - const struct radv_shader_stage *stage = &gfx_state->stages[s]; + if (gfx_state->stages) { + for (unsigned s = 0; s < MESA_VULKAN_SHADER_STAGES; s++) { + const struct radv_shader_stage *stage = &gfx_state->stages[s]; - if (stage->stage == MESA_SHADER_NONE) - continue; + if (stage->stage == MESA_SHADER_NONE) + continue; - _mesa_sha1_update(&ctx, stage->shader_sha1, sizeof(stage->shader_sha1)); - _mesa_sha1_update(&ctx, &stage->key, sizeof(stage->key)); + _mesa_sha1_update(&ctx, stage->shader_sha1, sizeof(stage->shader_sha1)); + _mesa_sha1_update(&ctx, &stage->key, sizeof(stage->key)); + } } _mesa_sha1_final(&ctx, hash);