perf: Do not double free
[cascardo/linux.git] / kernel / events / core.c
index d7b0316..211a5ce 100644 (file)
@@ -8520,7 +8520,12 @@ err_context:
        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: