* [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization
@ 2017-12-27 22:49 Andi Kleen
2017-12-28 11:35 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2017-12-27 22:49 UTC (permalink / raw)
To: peterz; +Cc: linux-kernel, Andi Kleen, Tommi Rantala
From: Andi Kleen <ak@linux.intel.com>
Tommi reports:
I'm seeing this kmemleak report in v4.15-rc4:
unreferenced object 0xffff8801f3d5d720 (size 64):
comm "swapper/0", pid 1, jiffies 4294667312 (age 2687.423s)
hex dump (first 32 bytes):
60 d1 41 ad ff ff ff ff 20 d1 41 ad ff ff ff ff `.A..... .A.....
80 d0 41 ad ff ff ff ff 40 d0 41 ad ff ff ff ff ..A.....@.A.....
backtrace:
[<00000000ab01886a>] intel_pmu_init+0x1844/0x1d38
[<00000000cf20c5f0>] init_hw_perf_events+0x8c/0x66f
[<00000000dd69189d>] do_one_initcall+0x7b/0x1d0
[<000000008ee1f02a>] kernel_init_freeable+0x163/0x2f9
[<00000000e32ca8d9>] kernel_init+0xf/0x120
[<0000000038a99264>] ret_from_fork+0x24/0x30
[<00000000ace6d26f>] 0xffffffffffffffff
$ ./scripts/faddr2line vmlinux intel_pmu_init+0x1844/0x1d38
intel_pmu_init+0x1844/0x1d38:
intel_pmu_init at arch/x86/events/intel/core.c:4296
Which matches line:
extra_attr = merge_attr(extra_attr, skl_format_attr);
So looks like "extra_attr" is leaked here.
Free the attribute in this case.
Reported-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Tommi Rantala <tommi.t.rantala@nokia.com>
Fixes: a5df70c354c26 ( perf/x86: Only show format attributes)
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/events/intel/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 09c26a4f139c..71321f48e1e6 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3855,6 +3855,7 @@ __init int intel_pmu_init(void)
struct extra_reg *er;
int version, i;
struct attribute **extra_attr = NULL;
+ bool extra_attr_allocated = false;
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);
+ extra_attr_allocated = true;
x86_pmu.cpu_events = get_hsw_events_attrs();
intel_pmu_pebs_data_source_skl(
boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X);
@@ -4324,6 +4326,8 @@ __init int intel_pmu_init(void)
if (version >= 2 && extra_attr) {
x86_pmu.format_attrs = merge_attr(intel_arch3_formats_attr,
extra_attr);
+ if (extra_attr_allocated)
+ kfree(extra_attr);
WARN_ON(!x86_pmu.format_attrs);
}
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization
2017-12-27 22:49 [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization Andi Kleen
@ 2017-12-28 11:35 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2017-12-28 11:35 UTC (permalink / raw)
To: Andi Kleen; +Cc: peterz, linux-kernel, Andi Kleen, Tommi Rantala
On Wed, 27 Dec 2017, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
Fixed that yesterday already slightly different.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-28 11:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-27 22:49 [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization Andi Kleen
2017-12-28 11:35 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox