etnaviv: Fix memory leak on error path.

Fix warning reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable pq going out of scope leaks the storage it
points to.

Suggested-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Fixes: eed5a00989 ("etnaviv: convert perfmon queries to acc queries")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5220>
(cherry picked from commit f047d585ee)
This commit is contained in:
Vinson Lee 2020-05-26 15:54:06 -07:00 committed by Eric Engestrom
parent 70681d4f9a
commit 094668b7cc
2 changed files with 6 additions and 5 deletions

View file

@ -3334,7 +3334,7 @@
"description": "etnaviv: Fix memory leak on error path.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "eed5a009897a859ec118ef84c0437be174a49da3"
},

View file

@ -101,12 +101,9 @@ perfmon_supports(unsigned query_type)
static struct etna_acc_query *
perfmon_allocate(struct etna_context *ctx, unsigned query_type)
{
struct etna_pm_query *pq = CALLOC_STRUCT(etna_pm_query);
struct etna_pm_query *pq;
const struct etna_perfmon_config *cfg;
if (!pq)
return NULL;
cfg = etna_pm_query_config(query_type);
if (!cfg)
return false;
@ -114,6 +111,10 @@ perfmon_allocate(struct etna_context *ctx, unsigned query_type)
if (!etna_pm_cfg_supported(ctx->screen->perfmon, cfg))
return false;
pq = CALLOC_STRUCT(etna_pm_query);
if (!pq)
return NULL;
pm_add_signal(pq, ctx->screen->perfmon, cfg);
return &pq->base;