Linux Perf Users
 help / color / mirror / Atom feed
From: liujing <liujing@cmss.chinamobile.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Liu Jing <liujing@cmss.chinamobile.com>
Subject: [PATCH] perf arm: Fix memory leak in find_all_arm_spe_pmus()
Date: Thu,  3 Sep 2026 16:21:28 +0800	[thread overview]
Message-ID: <20260903082128.4972-4-liujing@cmss.chinamobile.com> (raw)
In-Reply-To: <20260903082128.4972-1-liujing@cmss.chinamobile.com>

From: Liu Jing <liujing@cmss.chinamobile.com>

In find_all_arm_spe_pmus(), if sprintf() fails, the function returns NULL
without freeing the previously allocated arm_spe_pmus array, causing a
memory leak.

Fix it by adding free(arm_spe_pmus) before the return NULL statement.

Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
--- a/tools/perf/arch/arm/util/auxtrace.c
+++ b/tools/perf/arch/arm/util/auxtrace.c
@@ -39,6 +39,7 @@
 		if (ret < 0) {
 			pr_err("sprintf failed\n");
 			*err = -ENOMEM;
+			free(arm_spe_pmus);
 			return NULL;
 		}
 





  parent reply	other threads:[~2026-09-03  8:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  8:21 [PATCH] perf sched: Fix resource leak in enable_sched_schedstats() liujing
2026-09-03  8:21 ` [PATCH] perf intel-pt: Fix undefined shift in intel_pt_bip() liujing
2026-09-03  8:31   ` sashiko-bot
2026-09-08 20:58     ` Arnaldo Carvalho de Melo
2026-09-03  8:21 ` [PATCH] perf script: Fix unsigned comparison against zero in print_bstack_flags() liujing
2026-09-03  8:26   ` sashiko-bot
2026-09-03  8:21 ` liujing [this message]
2026-09-03  8:31   ` [PATCH] perf arm: Fix memory leak in find_all_arm_spe_pmus() sashiko-bot
2026-09-03  8:33 ` [PATCH] perf sched: Fix resource leak in enable_sched_schedstats() sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260903082128.4972-4-liujing@cmss.chinamobile.com \
    --to=liujing@cmss.chinamobile.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox