diff --git a/kernel/events/core.c b/kernel/events/core.c index d7b0316e3465faf742d8add01883c173dc32c67d..211a5ce64e3f7ce6852dde19788cd81543e8163e 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8520,7 +8520,12 @@ SYSCALL_DEFINE5(perf_event_open, perf_unpin_context(ctx); put_ctx(ctx); err_alloc: - free_event(event); + /* + * If event_file is set, the fput() above will have called ->release() + * and that will take care of freeing the event. + */ + if (!event_file) + free_event(event); err_cpus: put_online_cpus(); err_task: