aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-09-09 04:04:47 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-20 13:53:57 -0400
commita1792cdacaf5180e04e07811e220c4a3b4a9c33e (patch)
tree1779eb1c8c047e30101f4799f62301339a7aaf2c
parent611a546bec3e1af2a87af0862398fc711dc47aef (diff)
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 <davem@davemloft.net> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Acked-by: David Miller <davem@davemloft.net> LKML-Reference: <1252483487.7746.164.camel@twins> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index dbdf712fae9e..a6c8b27553cd 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)
924 if (err) 924 if (err)
925 return err; 925 return err;
926 926
927 counter->destroy = hw_perf_counter_destroy;
928
927 /* 929 /*
928 * Generate PMC IRQs: 930 * Generate PMC IRQs:
929 * (keep 'enabled' bit clear for now) 931 * (keep 'enabled' bit clear for now)
@@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
953 return -EOPNOTSUPP; 955 return -EOPNOTSUPP;
954 } 956 }
955 957
956 counter->destroy = hw_perf_counter_destroy;
957
958 /* 958 /*
959 * Raw event type provide the config in the event structure 959 * Raw event type provide the config in the event structure
960 */ 960 */
@@ -2107,8 +2107,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
2107 int err; 2107 int err;
2108 2108
2109 err = __hw_perf_counter_init(counter); 2109 err = __hw_perf_counter_init(counter);
2110 if (err) 2110 if (err) {
2111 if (counter->destroy)
2112 counter->destroy(counter);
2111 return ERR_PTR(err); 2113 return ERR_PTR(err);
2114 }
2112 2115
2113 return &pmu; 2116 return &pmu;
2114} 2117}