Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1361316

[PATCH] perf: fix event leak when perf_event_open() failed to create event_file

From Leon Yu <chianglungyu@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] perf: fix event leak when perf_event_open() failed to create event_file
Date 2016-03-20 17:00 +0100
Message-ID <reNVM-sU-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


If something went wrong in anon_inode_getfile, event_file will be set to
non-zero error number and able to bypass the NULL test afterward.

Consolidate the error path by testing event_file with handly
IS_ERR_OR_NULL() helper since we do want to free event in both cases.

Signed-off-by: Leon Yu <chianglungyu@gmail.com>
Fixes: 130056275ade ("perf: Do not double free")
Cc: <stable@vger.kernel.org> # v4.5
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6146148..5f2e19f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8617,7 +8617,7 @@ err_alloc:
 	 * If event_file is set, the fput() above will have called ->release()
 	 * and that will take care of freeing the event.
 	 */
-	if (!event_file)
+	if (IS_ERR_OR_NULL(event_file))
 		free_event(event);
 err_cpus:
 	put_online_cpus();
-- 
2.7.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] perf: fix event leak when perf_event_open() failed to create event_file Leon Yu <chianglungyu@gmail.com> - 2016-03-20 17:00 +0100
  Re: [PATCH] perf: fix event leak when perf_event_open() failed to create event_file Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-03-21 09:10 +0100
    Re: [PATCH] perf: fix event leak when perf_event_open() failed to  create event_file Leon Yu <chianglungyu@gmail.com> - 2016-03-21 16:30 +0100
    [tip:perf/core] perf/core: Don't leak event in the syscall error  path tip-bot for Alexander Shishkin <tipbot@zytor.com> - 2016-03-31 11:30 +0200

csiph-web