Commit 0258282e authored by Stephane Eranian's avatar Stephane Eranian Committed by Greg Kroah-Hartman

perf_events: Fix resource leak in x86 __hw_perf_event_init()

commit 4b24a88b upstream.

If reserve_pmc_hardware() succeeds but reserve_ds_buffers()
fails, then we need to release_pmc_hardware. It won't be done
by the destroy() callback because we return before setting it
in case of error.
Signed-off-by: default avatarStephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: paulus@samba.org
Cc: davem@davemloft.net
Cc: fweisbec@gmail.com
Cc: robert.richter@amd.com
Cc: perfmon2-devel@lists.sf.net
LKML-Reference: <4ba1568b.15185e0a.182a.7802@mx.google.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 181e8191
...@@ -460,8 +460,11 @@ static int __hw_perf_event_init(struct perf_event *event) ...@@ -460,8 +460,11 @@ static int __hw_perf_event_init(struct perf_event *event)
if (atomic_read(&active_events) == 0) { if (atomic_read(&active_events) == 0) {
if (!reserve_pmc_hardware()) if (!reserve_pmc_hardware())
err = -EBUSY; err = -EBUSY;
else else {
err = reserve_bts_hardware(); err = reserve_bts_hardware();
if (err)
release_pmc_hardware();
}
} }
if (!err) if (!err)
atomic_inc(&active_events); atomic_inc(&active_events);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment