Mesa (main): asahi: Move assignment after null check.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 15 13:58:12 UTC 2021


Module: Mesa
Branch: main
Commit: f5c8761edab0f3982ab22de774afa81148b47795
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f5c8761edab0f3982ab22de774afa81148b47795

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Wed Jul 14 22:23:09 2021 -0700

asahi: Move assignment after null check.

Fix defect reported by Coverity Scan.

Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking so suggests that it may be null,
but it has already been dereferenced on all paths leading to the
check.

Fixes: dcd2d8ca500 ("asahi: Track more Gallium state")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11898>

---

 src/gallium/drivers/asahi/agx_state.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c
index ba81bd278a8..71a991798dd 100644
--- a/src/gallium/drivers/asahi/agx_state.c
+++ b/src/gallium/drivers/asahi/agx_state.c
@@ -828,11 +828,12 @@ agx_create_shader_state(struct pipe_context *pctx,
                         const struct pipe_shader_state *cso)
 {
    struct agx_uncompiled_shader *so = CALLOC_STRUCT(agx_uncompiled_shader);
-   so->base = *cso;
 
    if (!so)
       return NULL;
 
+   so->base = *cso;
+
    if (cso->type == PIPE_SHADER_IR_NIR) {
       so->nir = cso->ir.nir;
    } else {



More information about the mesa-commit mailing list