Re: [PATCH] mce: fix warning messages about static struct mce_device

From: Alan Stern
Date: Thu Jan 19 2012 - 10:13:22 EST


On Thu, 19 Jan 2012, Srivatsa S. Bhat wrote:

> On 01/19/2012 06:02 PM, Ingo Molnar wrote:

> > But this is not what happened here - it's a special piece of
> > fundamental hardware that doesnt hot-plug separately from the
> > CPU and that has just a single "user".
> >
> > So i'm curious, why wasn't the memset() enough? It should have
> > resolved the bug AFAICS.
> >
>
>
> It did! The memset _did_ fix the bug.

But will it continue to fix the bug in the future?

Or to put it another way, even though no code takes references to these
device structures (can you really guarantee that even now?), how do you
prevent references being taken in future versions of the kernel?
Calling memset while there still are outstanding references very
definitely _is_ a bug.

IIRC, it used to be completely impossible to prevent this from
happening because sysfs would take references whenever user tasks
opened attribute files. Sysfs no longer does this, but the basic
principle of defensive programming still applies.

Alan Stern

--
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/