Skip to content

Commit

Permalink
perf_counter: x86: Fix PMU resource leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 20, 2009
1 parent 611a546 commit a1792cd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a1792cd

Please sign in to comment.