From 83ed419cd0a55fc0ee9f5ccce8f7ac03711bbf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Fri, 10 Nov 2023 10:01:46 +0100 Subject: [PATCH] zink: fix dereference before NULL check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `sv->image_view` pointer is dereference before checking whether it's NULL or not. Check for NULL before dereferencing it to avoid a possible crash. Fixes: 9de455bc4323 ("zink: check for sampler view existence during zink_rebind_all_images()") Reviewed-by: Dave Airlie Signed-off-by: José Expósito Part-of: --- src/gallium/drivers/zink/zink_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 52c1bcf76cc..45e1ca49f8f 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -4878,7 +4878,7 @@ zink_rebind_all_images(struct zink_context *ctx) for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { for (unsigned j = 0; j < ctx->di.num_sampler_views[i]; j++) { struct zink_sampler_view *sv = zink_sampler_view(ctx->sampler_views[i][j]); - if (!sv || sv->image_view->base.texture->target == PIPE_BUFFER || !sv->image_view) + if (!sv || !sv->image_view || sv->image_view->base.texture->target == PIPE_BUFFER) continue; struct zink_resource *res = zink_resource(sv->image_view->base.texture); if (res->obj != sv->image_view->obj) {