From 997dc0a5e87cde58b4527185ed89196261164801 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 6 May 2022 17:17:50 -0700 Subject: [PATCH] radeonsi: Move NULL check before dereference. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix defect reported by Coverity Scan. Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking desc suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Fixes: 2f83dce059 ("radeonsi: don't report R64_*INT as a sampler format because it doesn't work") Signed-off-by: Vinson Lee Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index f1b086662e5..8422029eadf 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2188,6 +2188,9 @@ static bool si_is_sampler_format_supported(struct pipe_screen *screen, enum pipe struct si_screen *sscreen = (struct si_screen *)screen; const struct util_format_description *desc = util_format_description(format); + if (!desc) + return false; + /* Samplers don't support 64 bits per channel. */ if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN && desc->channel[0].size == 64) @@ -2200,9 +2203,6 @@ static bool si_is_sampler_format_supported(struct pipe_screen *screen, enum pipe return true; } - if (!desc) - return false; - return si_translate_texformat(screen, format, desc, util_format_get_first_non_void_channel(format)) != ~0U; }