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

From: Peter Zijlstra
Date: Wed Nov 15 2023 - 04:58:35 EST


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.