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: 6173cc19c4 ("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 0a7bd14dbb)
This commit is contained in:
Vinson Lee 2020-09-28 16:16:37 -07:00 committed by Dylan Baker
parent 6ea01cd07a
commit f3f44dbf63
2 changed files with 5 additions and 4 deletions

View file

@ -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"
},

View file

@ -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);