perf pmu: Improve exception handling in perf_pmu__lookup()
Subsystems (2)
PATCH 1/1 perf pmu: Improve exception handling in perf_pmu__lookup()
From: Markus Elfring <[email protected]>
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 <[email protected]>
--- tools/perf/util/pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/pmu.c +2 -1
@@ -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 charreturn pmu; err:zfree (&pmu->name); +free_pmu:free (pmu);return NULL ; }
--
2.48.1