This is a note to let you know that I've just added the patch titled
perf/x86/intel: Plug memory leak in intel_pmu_init()
to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git%3Ba=su...
The filename of the patch is: perf-x86-intel-plug-memory-leak-in-intel_pmu_init.patch and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let stable@vger.kernel.org know about it.
From foo@baz Wed Feb 28 16:23:28 CET 2018
From: Thomas Gleixner tglx@linutronix.de Date: Wed, 27 Dec 2017 19:45:31 +0100 Subject: perf/x86/intel: Plug memory leak in intel_pmu_init()
From: Thomas Gleixner tglx@linutronix.de
[ Upstream commit 7ad1437d6ace0e450a6c1167720608ad660b191d ]
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 Signed-off-by: Sasha Levin alexander.levin@verizon.com Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org --- arch/x86/events/intel/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
--- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3847,6 +3847,8 @@ static struct attribute *intel_pmu_attrs
__init int intel_pmu_init(void) { + struct attribute **extra_attr = NULL; + struct attribute **to_free = NULL; union cpuid10_edx edx; union cpuid10_eax eax; union cpuid10_ebx ebx; @@ -3854,7 +3856,6 @@ __init int intel_pmu_init(void) unsigned int unused; struct extra_reg *er; int version, i; - struct attribute **extra_attr = NULL; char *name;
if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { @@ -4294,6 +4295,7 @@ __init int intel_pmu_init(void) extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? hsw_format_attr : nhm_format_attr; extra_attr = merge_attr(extra_attr, skl_format_attr); + to_free = extra_attr; x86_pmu.cpu_events = get_hsw_events_attrs(); intel_pmu_pebs_data_source_skl( boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X); @@ -4401,6 +4403,7 @@ __init int intel_pmu_init(void) pr_cont("full-width counters, "); }
+ kfree(to_free); return 0; }
Patches currently in stable-queue which might be from tglx@linutronix.de are
queue-4.14/exec-avoid-gcc-8-warning-for-get_task_comm.patch queue-4.14/perf-x86-intel-plug-memory-leak-in-intel_pmu_init.patch queue-4.14/x86-efi-fix-kernel-param-add_efi_memmap-regression.patch queue-4.14/x86-platform-intel-mid-revert-make-bt_sfi_data-const.patch queue-4.14/x86-asm-allow-again-using-asm.h-when-building-for-the-bpf-clang-target.patch queue-4.14/x86-stacktrace-make-zombie-stack-traces-reliable.patch queue-4.14/ia64-sched-cputime-fix-build-error-if-config_virt_cpu_accounting_native-y.patch queue-4.14/genirq-guard-handle_bad_irq-log-messages.patch queue-4.14/hrtimer-ensure-posix-compliance-relative-clock_realtime-hrtimers.patch