Simplify the code by changing the place of event->destroy(). Signed-off-by: Deng-Cheng Zhu <dczhu@xxxxxxxx> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx> Cc: David Daney <david.daney@xxxxxxxxxx> --- arch/mips/kernel/perf_event.c | 6 +----- arch/mips/kernel/perf_event_mipsxx.c | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c index b1d51b5..7a8d0a0 100644 --- a/arch/mips/kernel/perf_event.c +++ b/arch/mips/kernel/perf_event.c @@ -397,11 +397,7 @@ static int mipspmu_event_init(struct perf_event *event) if (err) return err; - err = __hw_perf_event_init(event); - if (err) - hw_perf_event_destroy(event); - - return err; + return __hw_perf_event_init(event); } static struct pmu pmu = { diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index c804fdd..bd75473 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -628,6 +628,9 @@ static int __hw_perf_event_init(struct perf_event *event) event->destroy = hw_perf_event_destroy; + if (err) + event->destroy(event); + return err; } -- 1.7.1