summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinson Lee <vlee@freedesktop.org>2020-09-28 16:16:37 -0700
committerEric Engestrom <eric@engestrom.ch>2020-10-14 19:29:29 +0200
commitbd5400ce988357a69479c1a888d4fed977beee13 (patch)
treeebdadf3ba2549b2ca371f3018ef2ebf104cd6efb
parentfec868f68f768983d0d40063d695b4dc68495287 (diff)
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 <vlee@freedesktop.org> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6903> (cherry picked from commit 0a7bd14dbb8c1c44cfa31abd584f57379f609489)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/.pick_status.json b/.pick_status.json
index bee1b01a30f..b7976a7bb78 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -8644,7 +8644,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 e6016189edf..fe0a41450b3 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -1108,6 +1108,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;
@@ -1118,9 +1122,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);