From patchwork Wed Sep 1 09:04:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 146481 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o81953bH000314 for ; Wed, 1 Sep 2010 09:05:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753617Ab0IAJEl (ORCPT ); Wed, 1 Sep 2010 05:04:41 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:59727 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828Ab0IAJEk convert rfc822-to-8bit (ORCPT ); Wed, 1 Sep 2010 05:04:40 -0400 Received: from f199130.upc-f.chello.nl ([80.56.199.130] helo=laptop) by bombadil.infradead.org with esmtpsa (Exim 4.72 #1 (Red Hat Linux)) id 1OqjF8-0008Bz-Ge; Wed, 01 Sep 2010 09:04:34 +0000 Received: by laptop (Postfix, from userid 1000) id C4119107D6E8C; Wed, 1 Sep 2010 11:04:28 +0200 (CEST) Subject: Re: ftrace/perf_event leak From: Peter Zijlstra To: Avi Kivity Cc: Ingo Molnar , Frederic Weisbecker , Steven Rostedt , kvm-devel , Linux Kernel Mailing List In-Reply-To: <4C7E11E5.1040402@redhat.com> References: <4C7E11E5.1040402@redhat.com> Date: Wed, 01 Sep 2010 11:04:28 +0200 Message-ID: <1283331868.2059.808.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 01 Sep 2010 09:05:17 +0000 (UTC) diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c index 000e6e8..35051f2 100644 --- a/kernel/trace/trace_event_perf.c +++ b/kernel/trace/trace_event_perf.c @@ -88,10 +88,11 @@ int perf_trace_init(struct perf_event *p_event) mutex_lock(&event_mutex); list_for_each_entry(tp_event, &ftrace_events, list) { if (tp_event->event.type == event_id && - tp_event->class && tp_event->class->reg && - try_module_get(tp_event->mod)) { - ret = perf_trace_event_init(tp_event, p_event); - break; + tp_event->class && tp_event->class->reg) { + if (try_module_get(tp_event->mod)) { + ret = perf_trace_event_init(tp_event, p_event); + break; + } } } mutex_unlock(&event_mutex); @@ -138,6 +139,7 @@ void perf_trace_destroy(struct perf_event *p_event) free_percpu(tp_event->perf_events); tp_event->perf_events = NULL; + module_put(tp_event->mod); if (!--total_ref_count) { for (i = 0; i < 4; i++) {