From: Leon Yu <chianglungyu@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Leon Yu <chianglungyu@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
<stable@vger.kernel.org>
Subject: [PATCH] perf: fix event leak when perf_event_open() failed to create event_file
Date: Sun, 20 Mar 2016 23:52:15 +0800 [thread overview]
Message-ID: <1458489135-5016-1-git-send-email-chianglungyu@gmail.com> (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
next reply other threads:[~2016-03-20 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 15:52 Leon Yu [this message]
2016-03-21 8:02 ` Alexander Shishkin
2016-03-21 15:21 ` Leon Yu
2016-03-31 9:19 ` [tip:perf/core] perf/core: Don't leak event in the syscall error path tip-bot for Alexander Shishkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458489135-5016-1-git-send-email-chianglungyu@gmail.com \
--to=chianglungyu@gmail.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®