Re: [v2 1/2] soc: fsl: dpio: Use scope-based resource management in dpaa2_io_store_create()

Ioana Ciornei <[email protected]> Tue, 28 Jul 2026 13:40:49 +0300
Newsgroups gmane.linux.kernel.janitors,gmane.linux.ports.arm.kernel,gmane.linux.ports.ppc64.devel,gmane.linux.kernel
Message-ID <6woig227u5snmdsrjfuw7gfcf3vk5iwaap4yf7ow6b6s3pba7z@yg4vmdoaak3h>
On Tue, Jul 28, 2026 at 08:55:38AM +0200, Markus Elfring wrote:
> >> https://elixir.bootlin.com/linux/v7.2-rc4/source/include/linux/cleanup.h#L142-L146
> > 
> > The context for the recommendation linked by you is (also from
> > cleanup.h):
> > 
> > 	 * "When multiple variables in the same scope have cleanup attributes,
> > 	 * at exit from the scope their associated cleanup functions are run in
> > 	 * reverse order of definition (last defined, first cleanup)."
> > 	 *
> > 	 * When the unwind order matters it requires that variables be defined
> > 	 * mid-function scope rather than at the top of the file.  Take the
> > 	 * following example and notice the bug highlighted by "!!"::
> > 
> > Which is not the case of these simple functions which only need a kfree.
> How will development concerns evolve further also according to previous clarification attempts?
> 
> Clarifying confusion of our variable placement rules caused by cleanup.h
> https://lore.kernel.org/ksummit/CAHk-=whPZoi03ZwphxiW6cuWPtC3nyKYS8_BThgztCdgPWP1WA@mail.gmail.com/
> https://lkml.org/lkml/2025/11/18/1766

My preference still stands and I do not think they contradict the views
expressed in the above links:
- Variables which do not have anything to do with cleanup.h should still
  be defined at the start of the function. This is the case of the
  qman_256_cycles_per_ns which you moved in 2/2 without any motive.
- In the case of a variable used with __free, if it can be done, I
  prefer to see the definition and initialization done at the start of
  the function.
  For example:

	struct dpaa2_io *obj __free(kfree) = kmalloc_obj(*obj);
	u32 qman_256_cycles_per_ns;

	if (!obj)
		return NULL;


I am not going to engage past this message.

Ioana