Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+4 -1
+4 -1
arch/x86/events/intel/core.c
··· 3847 3847 3848 3848 __init int intel_pmu_init(void) 3849 3849 { 3850 + struct attribute **extra_attr = NULL; 3851 + struct attribute **to_free = NULL; 3850 3852 union cpuid10_edx edx; 3851 3853 union cpuid10_eax eax; 3852 3854 union cpuid10_ebx ebx; ··· 3856 3854 unsigned int unused; 3857 3855 struct extra_reg *er; 3858 3856 int version, i; 3859 - struct attribute **extra_attr = NULL; 3860 3857 char *name; 3861 3858 3862 3859 if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { ··· 4295 4294 extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? 4296 4295 hsw_format_attr : nhm_format_attr; 4297 4296 extra_attr = merge_attr(extra_attr, skl_format_attr); 4297 + to_free = extra_attr; 4298 4298 x86_pmu.cpu_events = get_hsw_events_attrs(); 4299 4299 intel_pmu_pebs_data_source_skl( 4300 4300 boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X); ··· 4403 4401 pr_cont("full-width counters, "); 4404 4402 } 4405 4403 4404 + kfree(to_free); 4406 4405 return 0; 4407 4406 } 4408 4407