Skip to content

Commit ef5de16

Browse files
tititiou36namhyung
authored andcommitted
perf pmu: Fix a potential memory leak in perf_pmu__lookup()
The commit in Fixes has reordered some code, but missed an error handling path. 'goto err' now, in order to avoid a memory leak in case of error. Fixes: f63a536 ("perf pmu: Merge JSON events with sysfs at load time") Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Cc: [email protected] Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/9538b2b634894c33168dfe9d848d4df31fd4d801.1693085544.git.christophe.jaillet@wanadoo.fr
1 parent eb94225 commit ef5de16

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/perf/util/pmu.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
10221022
* type value and format definitions. Load both right
10231023
* now.
10241024
*/
1025-
if (pmu_format(pmu, dirfd, name)) {
1026-
free(pmu);
1027-
return NULL;
1028-
}
1025+
if (pmu_format(pmu, dirfd, name))
1026+
goto err;
1027+
10291028
pmu->is_core = is_pmu_core(name);
10301029
pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
10311030

0 commit comments

Comments
 (0)