From: Steven Rostedt Subject: [PATCH] RCU trace fix possible mem-leak Date: Thu, 04 Oct 2007 11:16:50 -0400 Message-ID: <1191511010.15186.6.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: LKML , RT , Ingo Molnar , Thomas Gleixner , Peter Zijlstra To: "Paul E. McKenney" Return-path: Received: from ms-smtp-02.nyroc.rr.com ([24.24.2.56]:60739 "EHLO ms-smtp-02.nyroc.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756768AbXJDPSF (ORCPT ); Thu, 4 Oct 2007 11:18:05 -0400 Sender: linux-rt-users-owner@vger.kernel.org List-Id: linux-rt-users.vger.kernel.org [ For RCU trace which is not yet in mainline ] In the initialization of the RCU trace module, if rcupreempt_debugfs_init() fails, we never free the the trace buffer. This patch frees the trace buffer in case the debugfs fails. Signed-off-by: Steven Rostedt Index: linux-2.6.23-rc9-rt1/kernel/rcupreempt_trace.c =================================================================== --- linux-2.6.23-rc9-rt1.orig/kernel/rcupreempt_trace.c +++ linux-2.6.23-rc9-rt1/kernel/rcupreempt_trace.c @@ -309,11 +309,16 @@ out: static int __init rcupreempt_trace_init(void) { + int ret; + mutex_init(&rcupreempt_trace_mutex); rcupreempt_trace_buf = kmalloc(RCUPREEMPT_TRACE_BUF_SIZE, GFP_KERNEL); if (!rcupreempt_trace_buf) return 1; - return rcupreempt_debugfs_init(); + ret = rcupreempt_debugfs_init(); + if (ret) + kfree(rcupreempt_trace_buf); + return ret; } static void __exit rcupreempt_trace_cleanup(void)