* [PATCH] perf pmu: Improve exception handling in perf_pmu__lookup()
@ 2025-03-04 12:13 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2025-03-04 12:13 UTC (permalink / raw)
To: linux-perf-users, Adrian Hunter, Alexander Shishkin,
Arnaldo Carvalho de Melo, Ian Rogers, Ingo Molnar, James Clark,
Jiri Olsa, Kan Liang, Mark Rutland, Namhyung Kim, Peter Zijlstra
Cc: LKML, kernel-janitors, Gaosheng Cui, Jing Zhang, John Garry,
Kajol Jain, Ravi Bangoria, Rob Herring
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Mar 2025 12:55:05 +0100
A zfree() call is not helpful after a failed strdup(name) call in
this function implementation.
Thus use an other jump target instead.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
tools/perf/util/pmu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 57450c73fb63..74eb46390233 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1107,7 +1107,7 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
pmu->name = strdup(name);
if (!pmu->name)
- goto err;
+ goto free_pmu;
/*
* Read type early to fail fast if a lookup name isn't a PMU. Ensure
@@ -1155,6 +1155,7 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
return pmu;
err:
zfree(&pmu->name);
+free_pmu:
free(pmu);
return NULL;
}
--
2.48.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-04 12:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-04 12:13 [PATCH] perf pmu: Improve exception handling in perf_pmu__lookup() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®