Re: commit 7b025f3f85ed causes NULL pointer dereference

James Bottomley
2025-04-09T12:49:14Z

On Tue, 2025-04-08 at 22:46 +0200, Thomas Gleixner wrote:
[...]
> - retain_ptr(dev);
>   msix_update_entries(dev, entries);
> + retain_ptr(dev);
>   return 0;

Heh, well, that scores -6 on the Rusty scale "the name tells you how
not to use it" because retain_ptr would commonly be read to mean the
pointer retains its value. It would be nice if KASAN had compile time
markers that would cause a use after free build failure for this, but,
apparently, it doesn't. The cleanup annotations don't let us remove
the scope free function, which would otherwise let us match the use to
the name, so I think the name might have to change to something like
retain_and_null_ptr().

Regards,

James