From 433004dcff84dad9a794dd8e757bd2e03c584255 Mon Sep 17 00:00:00 2001 From: Saroj Kumar Date: Fri, 24 Jan 2025 16:51:02 +0530 Subject: [PATCH] ac/surface: fix missing NULL check in gfx12_select_swizle_mode() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add null check for surf pointer. Fixes segfault issue during start of gdm on gfx12. Signed-off-by: Saroj Kumar Reviewed-by: Marek Olšák Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/common/ac_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index 219ec5ffcc2..81ea12c4bde 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -2781,9 +2781,9 @@ static unsigned gfx12_select_swizzle_mode(struct ac_addrlib *addrlib, get_in.numMipLevels = in->numMipLevels; get_in.numSamples = in->numSamples; - if (surf->flags & RADEON_SURF_PREFER_4K_ALIGNMENT) { + if (surf && surf->flags & RADEON_SURF_PREFER_4K_ALIGNMENT) { get_in.maxAlign = 4 * 1024; - } else if (surf->flags & RADEON_SURF_PREFER_64K_ALIGNMENT) { + } else if (surf && surf->flags & RADEON_SURF_PREFER_64K_ALIGNMENT) { get_in.maxAlign = 64 * 1024; } else { get_in.maxAlign = info->has_dedicated_vram ? (256 * 1024) : (64 * 1024);