Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760201AbYCBXU1 (ORCPT ); Sun, 2 Mar 2008 18:20:27 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756428AbYCBXUS (ORCPT ); Sun, 2 Mar 2008 18:20:18 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:59850 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755903AbYCBXUR (ORCPT ); Sun, 2 Mar 2008 18:20:17 -0500 Subject: Re: [PATCH] leak less memory in failure paths of alloc_rt_sched_group() From: Peter Zijlstra To: Jesper Juhl Cc: LKML , Linus Torvalds , linux-mm@kvack.org, Ingo Molnar In-Reply-To: References: Content-Type: text/plain Date: Mon, 03 Mar 2008 00:19:52 +0100 Message-Id: <1204499992.6240.109.camel@lappy> Mime-Version: 1.0 X-Mailer: Evolution 2.21.90 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1159 Lines: 46 On Mon, 2008-03-03 at 00:09 +0100, Jesper Juhl wrote: > In kernel/sched.c b/kernel/sched.c::alloc_rt_sched_group() we currently do > some paired memory allocations, and if one fails we bail out without > freeing the previous one. > > If we fail inside the loop we should proably roll the whole thing back. > This patch does not do that, it simply frees the first member of the > paired alloc if the second fails. This is not perfect, but it's a simple > change that will, at least, result in us leaking a little less than we > currently do when an allocation fails. > > So, not perfect, but better than what we currently have. > Please consider applying. Doesn't the following handle that: sched_create_group() { ... if (!alloc_rt_sched_group()) goto err; ... err: free_sched_group(); } free_sched_group() { ... free_rt_sched_group(); ... } free_rt_sched_group() { free all relevant stuff } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/