Re: Buggy __free(kfree) usage pattern already in tree

From: Bartosz Golaszewski
Date: Fri Sep 15 2023 - 16:04:53 EST


On Fri, 15 Sept 2023 at 21:27, Bartosz Golaszewski
<bartosz.golaszewski@xxxxxxxxxx> wrote:
>

[snip!]

>
> Understood. I'll go with a modified version of maybe-sane. I'll send a
> v2 tomorrow and make sure to Cc you.
>

[snip!]

One more question wrt the __free() coding style.

Is the following acceptable:

void foo(void)
{
char *s __free(kfree) = NULL;

do_stuff();
s = kmalloc(42, GFP_KERNEL);
}

Or does it always have to be:

void foo(void)
{
do_stuff();
char *s __free(kfree) = kmalloc(42, GFP_KERNEL);
}

?

I guess it would be useful to get these rules into
Documentation/process/coding-style.rst at some point as we also have
an ongoing discussion about whether scoped guards should always
require curly braces[1] even for single statements.

Bartosz

[1] https://lore.kernel.org/lkml/CAMuHMdVYDSPGP48OXxi-s4GFegfzUu900ASBnRmMo=18UzmCrQ@xxxxxxxxxxxxxx/