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

Peter Zijlstra
2023-11-15T09:58:35Z

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?

And once it is set, we should call it.