Skip to contentSkip to conversation

x86/perf/amd_uncore: Plug reference leak

PATCH New Thomas Gleixner 2 participants 2 messages Feb 16, 2016 – Feb 17, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/perf/amd_uncore: Plug reference leak

Subject: x86/perf/amd_uncore: Plug reference leak
From: Thomas Gleixner <[email protected]>
Date: Wed, 03 Feb 2016 09:38:31 +0100

In the error path of amd_uncore_cpu_up_prepare() the newly allocated uncore struct is freed, but the percpu pointer still references it. Set it to NULL.

---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c |    2 ++
 1 file changed, 2 insertions(+)
arch/x86/kernel/cpu/perf_event_amd_uncore.c +2 -0
@@ -323,6 +323,8 @@ static int amd_uncore_cpu_up_prepare(uns
 	return 0;
 
 fail:
+	if (amd_uncore_nb)
+		*per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
 	kfree(uncore_nb);
 	return -ENOMEM;
 }
#1 lore raw

[tip:perf/core] perf/x86/amd/uncore: Plug reference leak

perf/x86/amd/uncore: Plug reference leak
Commit-ID:  8bc9162cd2bf37036c486b384ac445b59b334b04
Gitweb:     http://git.kernel.org/tip/8bc9162cd2bf37036c486b384ac445b59b334b04
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 16 Feb 2016 23:04:41 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 17 Feb 2016 08:36:09 +0100

perf/x86/amd/uncore: Plug reference leak

In the error path of amd_uncore_cpu_up_prepare() the newly allocated uncore struct is freed, but the percpu pointer still references it. Set it to NULL.

---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kernel/cpu/perf_event_amd_uncore.c +2 -0
index 4974274..8836fc9 100644
@@ -323,6 +323,8 @@ static int amd_uncore_cpu_up_prepare(unsigned int cpu)
 	return 0;
 
 fail:
+	if (amd_uncore_nb)
+		*per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
 	kfree(uncore_nb);
 	return -ENOMEM;
 }