Re: [PATCH] btf: Simplify BTF logic with use of __free(btf_put)

Steven Rostedt
2025-08-04T14:19:55Z

On Mon, 4 Aug 2025 22:26:45 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Fri, 1 Aug 2025 07:16:22 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > From: Steven Rostedt <rostedt@goodmis.org>
> >
> > Several functions need to call btf_put() on the btf pointer before it
> > returns leading to using "goto" branches to jump to the end to call
> > btf_put(btf). This can be simplified by introducing DEFINE_FREE() to allow
> > functions to define the btf descriptor with:
> >
> > struct btf *btf __free(btf_put) = NULL;
> >
> > Then the btf descriptor will always have btf_put() called on it if it
> > isn't NULL or ERR before exiting the function.
> >
> > Where needed, no_free_ptr(btf) is used to assign the btf descriptor to a
> > pointer that will be used outside the function.
> >
>
> Yeah, this looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks but Alexei already declined it.

I'm gonna respin where it is only used in the tracing code.

Thanks!

-- Steve