Module: Mesa
Branch: staging/20.2
Commit: f3f44dbf637c3c3eb22fafc843f4065877c5fd10
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3f44dbf637c3c3eb22fafc843f4065877c5fd10

Author: Vinson Lee <[email protected]>
Date:   Mon Sep 28 16:16:37 2020 -0700

freedreno: Move rsc NULL check to before rsc dereferences.

Fix defect reported by Coverity Scan.

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

Fixes: 6173cc19c45d ("freedreno: gallium driver for adreno")
Signed-off-by: Vinson Lee <[email protected]>
Reviewed-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6903>
(cherry picked from commit 0a7bd14dbb8c1c44cfa31abd584f57379f609489)

---

 .pick_status.json                                  | 2 +-
 src/gallium/drivers/freedreno/freedreno_resource.c | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 7a99e9f46e2..f1c8cde17cf 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -238,7 +238,7 @@
         "description": "freedreno: Move rsc NULL check to before rsc 
dereferences.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "6173cc19c45d92ef0b7bc6aa008aa89bb29abbda"
     },
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c 
b/src/gallium/drivers/freedreno/freedreno_resource.c
index 222e3bb0a2c..17543842ca0 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -1012,6 +1012,10 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
 {
        struct fd_screen *screen = fd_screen(pscreen);
        struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
+
+       if (!rsc)
+               return NULL;
+
        struct fdl_slice *slice = fd_resource_slice(rsc, 0);
        struct pipe_resource *prsc = &rsc->base;
 
@@ -1022,9 +1026,6 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
                        tmpl->array_size, tmpl->last_level, tmpl->nr_samples,
                        tmpl->usage, tmpl->bind, tmpl->flags);
 
-       if (!rsc)
-               return NULL;
-
        *prsc = *tmpl;
        fd_resource_layout_init(prsc);
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to