From: Andi Kleen <andi@firstfloor.org>
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Tommi Rantala <tommi.t.rantala@nokia.com>
Subject: [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization
Date: Wed, 27 Dec 2017 14:49:08 -0800 [thread overview]
Message-ID: <20171227224908.11007-1-andi@firstfloor.org> (raw)
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
next reply other threads:[~2017-12-27 22:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-27 22:49 Andi Kleen [this message]
2017-12-28 11:35 ` [PATCH] perf/x86/intel: Fix minor memleak on Skylake perf initialization Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171227224908.11007-1-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tommi.t.rantala@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox