[PATCH] perf arm: Fix memory leak in find_all_arm_spe_pmus()

From: liujing

Date: Thu Sep 03 2026 - 04:30:07 EST


From: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxxx>
---
--- 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;
}