Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LyjAG-0004rB-5U for mharc-grub-devel@gnu.org; Tue, 28 Apr 2009 04:59:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LyjAD-0004qI-Ve for grub-devel@gnu.org; Tue, 28 Apr 2009 04:59:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LyjAC-0004pn-VS for grub-devel@gnu.org; Tue, 28 Apr 2009 04:59:41 -0400 Received: from [199.232.76.173] (port=55467 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyjAC-0004ph-S9 for grub-devel@gnu.org; Tue, 28 Apr 2009 04:59:40 -0400 Received: from [74.93.104.97] (port=53365 helo=sunset.davemloft.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LyjA9-00018k-OB; Tue, 28 Apr 2009 04:59:37 -0400 Received: from localhost (localhost [127.0.0.1]) by sunset.davemloft.net (Postfix) with ESMTP id 9B43835C184; Tue, 28 Apr 2009 01:59:29 -0700 (PDT) Date: Tue, 28 Apr 2009 01:59:29 -0700 (PDT) Message-Id: <20090428.015929.115521917.davem@davemloft.net> To: grub-devel@gnu.org, proski@gnu.org From: David Miller In-Reply-To: <1240890645.29799.99.camel@mj> References: <1240882672.29799.10.camel@mj> <20090427.184533.105744402.davem@davemloft.net> <1240890645.29799.99.camel@mj> X-Mailer: Mew version 6.2.51 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Subject: Re: [PATCH] Re: Revision 2136 breaks two-disk configuarion X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2009 08:59:42 -0000 From: Pavel Roskin Date: Mon, 27 Apr 2009 23:50:45 -0400 > On Mon, 2009-04-27 at 18:45 -0700, David Miller wrote: > >> Thanks for fixing this Pavel. I suspect this bug is why the close was >> left as a NOP function all of this time. > > Maybe. > >> Please commit this as it seems you haven't already :-) > > I was about to commit it when I realized that the same could be done > using a reference counter in struct grub_partition. It may be an > overkill for this purpose, but maybe there will be more users of the > partition table in the future. Besides, this patch could set an > example. Please have a cursory look to make sure it's a good example. I think it's overkill at the moment. > +/* Return partition to be freed if it can be freed. */ > +static inline grub_partition_t > +grub_partition_unref (const grub_partition_t p) > +{ > + if (p && p->refcount-- <= 0) > + return p; If the reference count dips below zero, that should trigger an assertion rather than giving the pointer to the caller again which will potentially double-free memory or whatever.