From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: Re: ftrace/perf_event leak Date: Thu, 02 Sep 2010 09:20:38 +0800 Message-ID: <4C7EFBE6.3040408@cn.fujitsu.com> References: <4C7E11E5.1040402@redhat.com> <1283331868.2059.808.camel@laptop> <4C7E1C36.6070400@redhat.com> <4C7E1F12.8030304@cn.fujitsu.com> <4C7E2D1D.3080603@redhat.com> <1283338977.2059.938.camel@laptop> <20100901121518.GA5378@nowhere> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Peter Zijlstra , Avi Kivity , Ingo Molnar , Steven Rostedt , kvm-devel , Linux Kernel Mailing List To: Frederic Weisbecker Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:56573 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754042Ab0IBBPj (ORCPT ); Wed, 1 Sep 2010 21:15:39 -0400 In-Reply-To: <20100901121518.GA5378@nowhere> Sender: kvm-owner@vger.kernel.org List-ID: >> Subject: perf, trace: Fix module leak >> From: Li Zefan >> Date: Wed Sep 01 12:58:43 CEST 2010 >> >> Commit 1c024eca (perf, trace: Optimize tracepoints by using >> per-tracepoint-per-cpu hlist to track events) caused a module refcount >> leak. >> >> Tested-by: Avi Kivity >> Signed-off-by: Peter Zijlstra >> LKML-Reference: <4C7E1F12.8030304@cn.fujitsu.com> >> --- >> kernel/trace/trace_event_perf.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> Index: linux-2.6/kernel/trace/trace_event_perf.c >> =================================================================== >> --- linux-2.6.orig/kernel/trace/trace_event_perf.c >> +++ linux-2.6/kernel/trace/trace_event_perf.c >> @@ -91,6 +91,8 @@ int perf_trace_init(struct perf_event *p >> tp_event->class && tp_event->class->reg && >> try_module_get(tp_event->mod)) { >> ret = perf_trace_event_init(tp_event, p_event); >> + if (ret) >> + module_put(tp_event->mod); >> break; >> } >> } >> @@ -147,6 +149,7 @@ void perf_trace_destroy(struct perf_even >> } >> } >> out: >> + module_put(tp_event->mod); >> mutex_unlock(&event_mutex); >> } >> >> > > Thanks for fixing this. > > However, can we split this in two patches to ease the backport? > > The lack of a module_put() after perf_trace_init() failure is there for a while > (the backport needs to start in 2.6.32). The failure should be a rare case, I don't think this has to be backported? > > But the lack of a module_put in the destroy path needs a .35 backport only. >