LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] perf: fix put_event() ctx leak
@ 2015-02-26 12:43 Leon Yu
  2015-03-13  4:53 ` Leon Yu
  2015-03-16 12:06 ` [tip:perf/urgent] perf: Fix context leak in put_event() tip-bot for Leon Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Yu @ 2015-02-26 12:43 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Leon Yu, linux-kernel

Commit a83fe28e2e45 ("perf: Fix put_event() ctx lock") changed lock logic in
put_event() by replacing mutex_lock_nested() with perf_event_ctx_lock_nested(),
but didn't fix subsequent mutex_unlock() with correct counterpart,
perf_event_ctx_unlock(). ctx is thus leaked as a result of incremented
refcount in perf_event_ctx_lock_nested().

Signed-off-by: Leon Yu <chianglungyu@gmail.com>
Fixes: a83fe28e2e45 ("perf: Fix put_event() ctx lock")
---
 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 f04daab..453ef61 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3591,7 +3591,7 @@ static void put_event(struct perf_event *event)
 	ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING);
 	WARN_ON_ONCE(ctx->parent_ctx);
 	perf_remove_from_context(event, true);
-	mutex_unlock(&ctx->mutex);
+	perf_event_ctx_unlock(event, ctx);
 
 	_free_event(event);
 }
-- 
2.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-16 12:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 12:43 [PATCH] perf: fix put_event() ctx leak Leon Yu
2015-03-13  4:53 ` Leon Yu
2015-03-16 12:06 ` [tip:perf/urgent] perf: Fix context leak in put_event() tip-bot for Leon Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).