Re: [PATCH v2 3/5] ACPI: Support __free() from cleanup.h for ACPI objects

Sakari Ailus <[email protected]>
Newsgroups org.kernel.vger.linux-acpi,org.kernel.vger.linux-media,org.kernel.vger.platform-driver-x86
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
Hi Rafael, Ilpo,

On Tue, Aug 25, 2026 at 03:08:07PM +0200, Rafael J. Wysocki (Intel) wrote:
> > If there is a cleanup.h "free" that can only be used with objects
> > returned by acpi_evaluate_dsm_typed(), I'll be fine with that.
> >
> > Or if everyone agrees that doing
> >
> >     union acpi_object *out_obj __free(ACPI_FREE) = NULL;
> >
> > is not confusing and fine, I may just say "Hey, I don't care that much".
> 
> And particularly there is this paragraph in a comment in cleanup.h:
> 
>  * Given that the "__free(...) = NULL" pattern for variables defined at
>  * the top of the function poses this potential interdependency problem
>  * the recommendation is to always define and assign variables in one
>  * statement and not group variable definitions at the top of the
>  * function when __free() is used.
> 
> regarding a broken code example, so I would think that this is not a
> made-up concern.

That's indeed a valid concern, still quite unlikely in practice but
probably hard to find when it happens, so avoiding that is definitely
preferred. That being said, the biggest trap in cleanup.h is probably in
scoped_guard(), and doing __free() = NULL somewhere doesn't matter much in
the end.

In this case I'll just call ACPI_FREE() sooner.

-- 
Regards,

Sakari Ailus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.