Re: [PATCH 01/15] kmemleak: Add the base support

From: Pekka Enberg
Date: Fri Dec 12 2008 - 08:15:29 EST


On Fri, 2008-12-12 at 11:36 +0000, Catalin Marinas wrote:
> On Fri, 2008-12-12 at 00:01 +0200, Pekka Enberg wrote:
> > On Wed, Dec 10, 2008 at 8:26 PM, Catalin Marinas
> > <catalin.marinas@xxxxxxx> wrote:
> > > +static void put_object(struct memleak_object *object)
> > > +{
> > > + if (!atomic_dec_and_test(&object->use_count))
> > > + return;
> > > +
> > > + /* should only get here after delete_object was called */
> > > + BUG_ON(object->flags & OBJECT_ALLOCATED);
> >
> > This could be
> >
> > if (WARN_ON(object->flags & OBJECT_ALLOCATED))
> > return;
>
> I'm not sure just warning would be enough. If this happens, its a severe
> bug in kmemleak and the tool is no longer useful (it could even leak
> memory or free already freed blocks). I could change it to a
> memleak_panic call but if the object use_count isn't reliable, the
> memleak_disable call wouldn't work properly either.

Oh, we use WARN_ON() for things like this as well to maximize the
likelihood of the oops actually reaching the user. But whatever works
for you the best.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/