[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251118141720.11c8d4d6@gandalf.local.home>
Date: Tue, 18 Nov 2025 14:17:20 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Bart Van Assche <bvanassche@....org>, James Bottomley
<James.Bottomley@...senpartnership.com>, ksummit@...ts.linux.dev, Dan
Williams <dan.j.williams@...el.com>, linux-kernel
<linux-kernel@...r.kernel.org>, Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: Clarifying confusion of our variable placement rules caused by
cleanup.h
On Tue, 18 Nov 2025 10:38:20 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> struct x509_parse_context *ctx __free(kfree) = NULL;
> ... other code ...
> ctx = kzalloc(sizeof(struct x509_parse_context), GFP_KERNEL);
>
> where you have now split up the whole "this is allocated by kmalloc,
> and free'd by kfree" into two different sections that are not next to
> each other.
I've been doing the above, and was even going to recommend it to James. But
if it is preferred to declare the __free() variables where they are
allocated, I'd be much happier.
I think the code could also be better optimized? I haven't run an objcopy to
confirm but now early exits do not require calling the __free() function on
NULL pointers.
Most of my code allocates near the top where I don't find this a problem,
but I do have a few places of:
struct foo *var __free(kfree) = NULL;
if (ret < 0)
return -ERROR;
[ several more error exits ]
var = kmalloc(..);
-- Steve
Powered by blists - more mailing lists