Module: Mesa Branch: main Commit: 83ed419cd0a55fc0ee9f5ccce8f7ac03711bbf71 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83ed419cd0a55fc0ee9f5ccce8f7ac03711bbf71
Author: José Expósito <[email protected]> Date: Fri Nov 10 10:01:46 2023 +0100 zink: fix dereference before NULL check 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 <[email protected]> Signed-off-by: José Expósito <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26140> --- 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) {
