perf/x86/rapl: Fix error handling in init_rapl_pmus()

If init_rapl_pmu() fails while allocating memory for "rapl_pmu" objects,
we miss freeing the "rapl_pmus" object in the error path. Fix that.

Fixes: 9b99d65c0bb4 ("perf/x86/rapl: Move the pmu allocation out of CPU hotplug")
Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250320100617.4480-1-dhananjay.ugwekar@amd.com

authored by Dhananjay Ugwekar and committed by Ingo Molnar 7e512f5a 65a99264

Changed files
+6 -1
arch
x86
events
+6 -1
arch/x86/events/rapl.c
··· 730 730 { 731 731 int nr_rapl_pmu = topology_max_packages(); 732 732 struct rapl_pmus *rapl_pmus; 733 + int ret; 733 734 734 735 /* 735 736 * rapl_pmu_scope must be either PKG, DIE or CORE ··· 762 761 rapl_pmus->pmu.module = THIS_MODULE; 763 762 rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE; 764 763 765 - return init_rapl_pmu(rapl_pmus); 764 + ret = init_rapl_pmu(rapl_pmus); 765 + if (ret) 766 + kfree(rapl_pmus); 767 + 768 + return ret; 766 769 } 767 770 768 771 static struct rapl_model model_snb = {