Re: p = kmalloc(sizeof(*p), )

Al Viro
2005-09-18T21:14:34Z

On Sun, Sep 18, 2005 at 10:30:26PM +0100, Alan Cox wrote:
> > It would be very useful when e.g. tracking down improper uses of
> > struct file, struct dentry, etc. - stuff that should always be
> > allocated by one helper function. Same goes for e.g. net_device -
>
> Another useful trick here btw is to make such objects contain (when
> debugging)
>
> void *magic_ptr;
>
> which is initialised as foo->magic_ptr = foo;
>
> That catches anyone copying them and tells you what got copied

At runtime, _if_ we do not forget to initialize it. Which is what
we are trying to catch...