public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* x86: Fix leak in uncore_type_init failure paths
@ 2014-03-06 17:20 Dave Jones
  2014-03-11 12:38 ` [tip:perf/urgent] perf/x86: " tip-bot for Dave Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jones @ 2014-03-06 17:20 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Peter Zijlstra, x86

The error path of uncore_type_init() frees up any allocations that were made
along the way, but it relies upon type->pmus being set, which only happens
if the function succeeds. As type->pmus remains null in this case, the call
to uncore_type_exit will do nothing.

Moving the assignment earlier will allow us to actually free those allocations
should something go awry.

Signed-off-by: Dave Jones <davej@fedoraproject.org>

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index c88f7f4b03ee..047f540cf3f7 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -3334,6 +3334,8 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
 	if (!pmus)
 		return -ENOMEM;
 
+	type->pmus = pmus;
+
 	type->unconstrainted = (struct event_constraint)
 		__EVENT_CONSTRAINT(0, (1ULL << type->num_counters) - 1,
 				0, type->num_counters, 0, 0);
@@ -3369,7 +3371,6 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
 	}
 
 	type->pmu_group = &uncore_pmu_attr_group;
-	type->pmus = pmus;
 	return 0;
 fail:
 	uncore_type_exit(type);

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

end of thread, other threads:[~2014-03-11 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-06 17:20 x86: Fix leak in uncore_type_init failure paths Dave Jones
2014-03-11 12:38 ` [tip:perf/urgent] perf/x86: " tip-bot for Dave Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox