Re: [RFC] slab: introduce auto_kfree macro

From: Linus Torvalds
Date: Thu Apr 03 2025 - 14:16:16 EST


On Tue, 1 Apr 2025 at 06:50, Przemek Kitszel
<przemyslaw.kitszel@xxxxxxxxx> wrote:
>
> With new auto_kfree, we simply will start with
> struct my_dev_foo *foo auto_kfree;
> and be safe against future extensions.

Honestly, I'd much rather just see any auto-freeing *always* assigning
the value.

We used to have a rule that declarations had to be at the top of a
block, which made that not an option, but that rule went out the
window exactly because you can't do that with the cleanup macros.

So just make the rule be that __free() without an assignment is simply a bug.

Linus