This is a note to let you know that I've just added the patch titled perf pmu: Fix a potential memory leak in perf_pmu__lookup() to the 6.7-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: perf-pmu-fix-a-potential-memory-leak-in-perf_pmu__lo.patch and it can be found in the queue-6.7 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit e814c8c5afc55f6b866aea07fa946eaedb14cb20 Author: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> Date: Sat Aug 26 23:32:45 2023 +0200 perf pmu: Fix a potential memory leak in perf_pmu__lookup() [ Upstream commit ef5de1613d7d92bdc975e6beb34bb0fa94f34078 ] 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: f63a536f03a2 ("perf pmu: Merge JSON events with sysfs at load time") Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx> Cc: kernel-janitors@xxxxxxxxxxxxxxx Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx> Link: https://lore.kernel.org/r/9538b2b634894c33168dfe9d848d4df31fd4d801.1693085544.git.christophe.jaillet@xxxxxxxxxx Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 33e783fc908fe..aaa013af52524 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1019,10 +1019,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char * type value and format definitions. Load both right * now. */ - if (pmu_format(pmu, dirfd, name)) { - free(pmu); - return NULL; - } + if (pmu_format(pmu, dirfd, name)) + goto err; + pmu->is_core = is_pmu_core(name); pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);