diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-12-27 13:45:31 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-12-27 14:23:59 -0500 |
commit | 7ad1437d6ace0e450a6c1167720608ad660b191d (patch) | |
tree | b518b1fd266c0f025683e91178ecd42e283b55bc | |
parent | 2e36463525b8b63b32be0721d0268e336d314b38 (diff) |
perf/x86/intel: Plug memory leak in intel_pmu_init()
A recent commit introduced an extra merge_attr() call in the skylake
branch, which causes a memory leak.
Store the pointer to the extra allocated memory and free it at the end of
the function.
Fixes: a5df70c354c2 ("perf/x86: Only show format attributes when supported")
Reported-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@linux.intel.com>
-rw-r--r-- | arch/x86/events/intel/core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 09c26a4f139c..731153a4681e 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c | |||
@@ -3847,6 +3847,8 @@ static struct attribute *intel_pmu_attrs[] = { | |||
3847 | 3847 | ||
3848 | __init int intel_pmu_init(void) | 3848 | __init int intel_pmu_init(void) |
3849 | { | 3849 | { |
3850 | struct attribute **extra_attr = NULL; | ||
3851 | struct attribute **to_free = NULL; | ||
3850 | union cpuid10_edx edx; | 3852 | union cpuid10_edx edx; |
3851 | union cpuid10_eax eax; | 3853 | union cpuid10_eax eax; |
3852 | union cpuid10_ebx ebx; | 3854 | union cpuid10_ebx ebx; |
@@ -3854,7 +3856,6 @@ __init int intel_pmu_init(void) | |||
3854 | unsigned int unused; | 3856 | unsigned int unused; |
3855 | struct extra_reg *er; | 3857 | struct extra_reg *er; |
3856 | int version, i; | 3858 | int version, i; |
3857 | struct attribute **extra_attr = NULL; | ||
3858 | char *name; | 3859 | char *name; |
3859 | 3860 | ||
3860 | if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { | 3861 | if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { |
@@ -4294,6 +4295,7 @@ __init int intel_pmu_init(void) | |||
4294 | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | 4295 | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? |
4295 | hsw_format_attr : nhm_format_attr; | 4296 | hsw_format_attr : nhm_format_attr; |
4296 | extra_attr = merge_attr(extra_attr, skl_format_attr); | 4297 | extra_attr = merge_attr(extra_attr, skl_format_attr); |
4298 | to_free = extra_attr; | ||
4297 | x86_pmu.cpu_events = get_hsw_events_attrs(); | 4299 | x86_pmu.cpu_events = get_hsw_events_attrs(); |
4298 | intel_pmu_pebs_data_source_skl( | 4300 | intel_pmu_pebs_data_source_skl( |
4299 | boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X); | 4301 | boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X); |
@@ -4401,6 +4403,7 @@ __init int intel_pmu_init(void) | |||
4401 | pr_cont("full-width counters, "); | 4403 | pr_cont("full-width counters, "); |
4402 | } | 4404 | } |
4403 | 4405 | ||
4406 | kfree(to_free); | ||
4404 | return 0; | 4407 | return 0; |
4405 | } | 4408 | } |
4406 | 4409 | ||