[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Re: Revision 2136 breaks two-disk configuarion

From: David Miller
Subject: Re: [PATCH] Re: Revision 2136 breaks two-disk configuarion
Date: Tue, 28 Apr 2009 01:59:29 -0700 (PDT)

From: Pavel Roskin <address@hidden>
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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]