From: Peter Zijlstra Date: Wed, 9 Sep 2009 08:04:47 +0000 (+0200) Subject: perf_counter: x86: Fix PMU resource leak X-Git-Tag: v2.6.32-rc1~613^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1792cdacaf5180e04e07811e220c4a3b4a9c33e;p=platform%2Fkernel%2Flinux-stable.git perf_counter: x86: Fix PMU resource leak Dave noticed that we leak the PMU resource reservations when we fail the hardware counter init. Reported-by: David Miller Signed-off-by: Peter Zijlstra Acked-by: David Miller LKML-Reference: <1252483487.7746.164.camel@twins> Signed-off-by: Ingo Molnar --- diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c index dbdf712..a6c8b27 100644 --- a/arch/x86/kernel/cpu/perf_counter.c +++ b/arch/x86/kernel/cpu/perf_counter.c @@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter) if (err) return err; + counter->destroy = hw_perf_counter_destroy; + /* * Generate PMC IRQs: * (keep 'enabled' bit clear for now) @@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter) return -EOPNOTSUPP; } - counter->destroy = hw_perf_counter_destroy; - /* * Raw event type provide the config in the event structure */ @@ -2107,8 +2107,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter) int err; err = __hw_perf_counter_init(counter); - if (err) + if (err) { + if (counter->destroy) + counter->destroy(counter); return ERR_PTR(err); + } return &pmu; }