Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756250AbcCBR6G (ORCPT ); Wed, 2 Mar 2016 12:58:06 -0500 Received: from mga14.intel.com ([192.55.52.115]:40423 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbcCBR6E (ORCPT ); Wed, 2 Mar 2016 12:58:04 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,529,1449561600"; d="scan'208";a="756866939" Date: Wed, 2 Mar 2016 09:58:37 -0800 (PST) From: Vikas Shivappa X-X-Sender: vikas@vshiva-Udesk To: Thomas Gleixner cc: Vikas Shivappa , vikas.shivappa@intel.com, linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, ravi.v.shankar@intel.com, tony.luck@intel.com, fenghua.yu@intel.com, h.peter.anvin@intel.com Subject: Re: [PATCH 2/6] x86,perf/cqm: Fix cqm memory leak and notifier leak In-Reply-To: Message-ID: References: <1456876108-28770-1-git-send-email-vikas.shivappa@linux.intel.com> <1456876108-28770-3-git-send-email-vikas.shivappa@linux.intel.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1785 Lines: 62 On Wed, 2 Mar 2016, Thomas Gleixner wrote: > On Tue, 1 Mar 2016, Vikas Shivappa wrote: > >> Fixes the hotcpu notifier leak and a memory leak during cqm(cache >> quality of service monitoring) initialization. >> >> Reviewed-by: Tony Luck >> Signed-off-by: Vikas Shivappa >> --- >> arch/x86/kernel/cpu/perf_event_intel_cqm.c | 17 ++++++++++++----- >> 1 file changed, 12 insertions(+), 5 deletions(-) >> >> diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c >> index e6be335..5666171 100644 >> --- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c >> +++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c >> @@ -1322,7 +1322,7 @@ static const struct x86_cpu_id intel_cqm_match[] = { >> >> static int __init intel_cqm_init(void) >> { >> - char *str, scale[20]; >> + char *str = NULL, scale[20]; >> int i, cpu, ret; >> >> if (!x86_match_cpu(intel_cqm_match)) >> @@ -1382,16 +1382,23 @@ static int __init intel_cqm_init(void) >> cqm_pick_event_reader(i); >> } >> >> - __perf_cpu_notifier(intel_cqm_cpu_notifier); >> - >> ret = perf_pmu_register(&intel_cqm_pmu, "intel_cqm", -1); >> - if (ret) >> + if (ret) { >> pr_err("Intel CQM perf registration failed: %d\n", ret); >> - else >> + goto out; >> + } else { >> pr_info("Intel CQM monitoring enabled\n"); >> + } >> >> + /* >> + * Register the hot cpu notifier once we are sure cqm >> + * is enabled to avoid notifier leak. >> + */ >> + __perf_cpu_notifier(intel_cqm_cpu_notifier); >> out: >> cpu_notifier_register_done(); >> + if (ret) >> + kfree(str); > > This still leaks cqm_rmid_ptrs .... > Thats right. Thought there must be something more than the str leak i fixed, but missed this. Will fix Thanks, Vikas