perf/x86: Fix leak in uncore_type_init failure paths
authorDave Jones <davej@redhat.com>
Thu, 6 Mar 2014 17:20:28 +0000 (12:20 -0500)
committerIngo Molnar <mingo@kernel.org>
Tue, 11 Mar 2014 10:59:34 +0000 (11:59 +0100)
commitb7b4839d93e50adccef29eccb694807cdcb8bee3
treed015228e464ce184074c50e63f5918f7ceec0ae1
parentb8ad0f912b93c23c34dfedc615a0eeba6ca29463
perf/x86: Fix leak in uncore_type_init failure paths

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>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140306172028.GA552@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/perf_event_intel_uncore.c