Re: commit 7b025f3f85ed causes NULL pointer dereference

Thomas Gleixner
2025-04-09T18:38:16Z

On Wed, Apr 09 2025 at 08:49, James Bottomley wrote:
> 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().

Yeah. When I saw it I immediately rumaged for a brown paperbag :)