Re: [PATCH 01/13] perf: Simplify perf_event_alloc() error path

Namhyung Kim
2023-11-15T15:13:06Z

On Wed, Nov 15, 2023 at 1:58 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Fri, Nov 03, 2023 at 12:50:19PM -0700, Namhyung Kim wrote:
>
> > > > -err_pmu:
> > > > - if (is_cgroup_event(event))
> > > > - perf_detach_cgroup(event);
> > > > - if (event->destroy)
> > > > - event->destroy(event);
> > > > - module_put(pmu->module);
> >
> > I'm afraid of this part. If it failed at perf_init_event(), it might
> > call event->destroy() already. I saw you cleared event->pmu
> > in the failure path. Maybe we need the same thing for the
> > event->destroy.
>
> In that case event->destroy will not yet have been set, no?

In perf_try_init_event(), it calls event->destroy() if set when it
has EXTENDED_REGS or NO_EXCLUDE capabilities and returns an error.

Thanks,
Namhyung