Skip to content

Commit

Permalink
perf: Do not double free
Browse files Browse the repository at this point in the history
commit 130056275ade730e7a79c110212c8815202773ee upstream.

In case of: err_file: fput(event_file), we'll end up calling
perf_release() which in turn will free the event.

Do not then free the event _again_.

Change-Id: I257fa040c467422d499599ef17d68d0463178a0a
Tested-by: Alexander Shishkin <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: Francisco Franco <[email protected]>
  • Loading branch information
Peter Zijlstra authored and franciscofranco committed Dec 9, 2017
1 parent 735e2a6 commit d7a6fc5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6645,7 +6645,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_task:
if (task)
put_task_struct(task);
Expand Down

0 comments on commit d7a6fc5

Please sign in to comment.