Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762408AbXK2Cop (ORCPT ); Wed, 28 Nov 2007 21:44:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755582AbXK2CoQ (ORCPT ); Wed, 28 Nov 2007 21:44:16 -0500 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:58704 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbXK2CoI (ORCPT ); Wed, 28 Nov 2007 21:44:08 -0500 Date: Thu, 29 Nov 2007 11:42:43 +0900 From: Yasunori Goto To: WANG Cong Subject: Re: [Patch](Resend) mm/sparse.c: Improve the error handling for sparse_add_one_section() Cc: Dave Hansen , LKML , Rik van Riel , Christoph Lameter , Andrew Morton , linux-mm@kvack.org, Andy Whitcroft In-Reply-To: <20071128124420.GJ2464@hacking> References: <1196189625.5764.36.camel@localhost> <20071128124420.GJ2464@hacking> X-Mailer-Plugin: BkASPil for Becky!2 Ver.2.068 Message-Id: <20071129113903.03E3.Y-GOTO@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.27 [ja] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2670 Lines: 98 Looks good to me. Thanks. Acked-by: Yasunori Goto > On Tue, Nov 27, 2007 at 10:53:45AM -0800, Dave Hansen wrote: > >On Tue, 2007-11-27 at 10:26 +0800, WANG Cong wrote: > >> > >> @@ -414,7 +418,7 @@ int sparse_add_one_section(struct zone * > >> out: > >> pgdat_resize_unlock(pgdat, &flags); > >> if (ret <= 0) > >> - __kfree_section_memmap(memmap, nr_pages); > >> + kfree(usemap); > >> return ret; > >> } > >> #endif > > > >Why did you get rid of the memmap free here? A bad return from > >sparse_init_one_section() indicates that we didn't use the memmap, so it > >will leak otherwise. > > Sorry, I was confused by the recursion. This one should be OK. > > Thanks. > > > > Improve the error handling for mm/sparse.c::sparse_add_one_section(). And I > see no reason to check 'usemap' until holding the 'pgdat_resize_lock'. > > Cc: Christoph Lameter > Cc: Dave Hansen > Cc: Rik van Riel > Cc: Yasunori Goto > Cc: Andy Whitcroft > Signed-off-by: WANG Cong > > --- > Index: linux-2.6/mm/sparse.c > =================================================================== > --- linux-2.6.orig/mm/sparse.c > +++ linux-2.6/mm/sparse.c > @@ -391,9 +391,17 @@ int sparse_add_one_section(struct zone * > * no locking for this, because it does its own > * plus, it does a kmalloc > */ > - sparse_index_init(section_nr, pgdat->node_id); > + ret = sparse_index_init(section_nr, pgdat->node_id); > + if (ret < 0) > + return ret; > memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, nr_pages); > + if (!memmap) > + return -ENOMEM; > usemap = __kmalloc_section_usemap(); > + if (!usemap) { > + __kfree_section_memmap(memmap, nr_pages); > + return -ENOMEM; > + } > > pgdat_resize_lock(pgdat, &flags); > > @@ -403,18 +411,16 @@ int sparse_add_one_section(struct zone * > goto out; > } > > - if (!usemap) { > - ret = -ENOMEM; > - goto out; > - } > ms->section_mem_map |= SECTION_MARKED_PRESENT; > > ret = sparse_init_one_section(ms, section_nr, memmap, usemap); > > out: > pgdat_resize_unlock(pgdat, &flags); > - if (ret <= 0) > + if (ret <= 0) { > + kfree(usemap); > __kfree_section_memmap(memmap, nr_pages); > + } > return ret; > } > #endif -- Yasunori Goto - 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/