From f047d585ee472a314d4ad5da4dffa5e7c2a42eb5 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 May 2020 15:54:06 -0700 Subject: [PATCH] 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 Fixes: eed5a009897a ("etnaviv: convert perfmon queries to acc queries") Signed-off-by: Vinson Lee Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_query_acc_perfmon.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_acc_perfmon.c b/src/gallium/drivers/etnaviv/etnaviv_query_acc_perfmon.c index 5a5ffdb5d61..7c49fc88fad 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_query_acc_perfmon.c +++ b/src/gallium/drivers/etnaviv/etnaviv_query_acc_perfmon.c @@ -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; -- 2.30.2