提交 a1792cda 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

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: NDavid Miller <davem@davemloft.net>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: NDavid Miller <davem@davemloft.net>
LKML-Reference: <1252483487.7746.164.camel@twins>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 611a546b
...@@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter) ...@@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
if (err) if (err)
return err; return err;
counter->destroy = hw_perf_counter_destroy;
/* /*
* Generate PMC IRQs: * Generate PMC IRQs:
* (keep 'enabled' bit clear for now) * (keep 'enabled' bit clear for now)
...@@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter) ...@@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
counter->destroy = hw_perf_counter_destroy;
/* /*
* Raw event type provide the config in the event structure * 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) ...@@ -2107,8 +2107,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
int err; int err;
err = __hw_perf_counter_init(counter); err = __hw_perf_counter_init(counter);
if (err) if (err) {
if (counter->destroy)
counter->destroy(counter);
return ERR_PTR(err); return ERR_PTR(err);
}
return &pmu; return &pmu;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册