diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-08-02 22:11:40 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-08-06 15:25:56 -0400 |
commit | 449e5b247ca7c9dc9fc3391b7eebfefdeb2ce1fc (patch) | |
tree | 22d9aafb65a2f5d921e278d02292c3feb3392614 /tools | |
parent | 58432e1f3625ef22b347ec8f9487e1852aa9ad67 (diff) |
perf probe: Fix memory leaks in add_perf_probe_events
Fix several memory leaks of pkgs and tevs in add_perf_probe_events().
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
LKML-Reference: <4C577ADC.1000309@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/probe-event.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2e665cb84055..e72f05c3bef0 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -1606,8 +1606,10 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, | |||
1606 | 1606 | ||
1607 | /* Init vmlinux path */ | 1607 | /* Init vmlinux path */ |
1608 | ret = init_vmlinux(); | 1608 | ret = init_vmlinux(); |
1609 | if (ret < 0) | 1609 | if (ret < 0) { |
1610 | free(pkgs); | ||
1610 | return ret; | 1611 | return ret; |
1612 | } | ||
1611 | 1613 | ||
1612 | /* Loop 1: convert all events */ | 1614 | /* Loop 1: convert all events */ |
1613 | for (i = 0; i < npevs; i++) { | 1615 | for (i = 0; i < npevs; i++) { |
@@ -1625,10 +1627,13 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs, | |||
1625 | ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs, | 1627 | ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs, |
1626 | pkgs[i].ntevs, force_add); | 1628 | pkgs[i].ntevs, force_add); |
1627 | end: | 1629 | end: |
1628 | /* Loop 3: cleanup trace events */ | 1630 | /* Loop 3: cleanup and free trace events */ |
1629 | for (i = 0; i < npevs; i++) | 1631 | for (i = 0; i < npevs; i++) { |
1630 | for (j = 0; j < pkgs[i].ntevs; j++) | 1632 | for (j = 0; j < pkgs[i].ntevs; j++) |
1631 | clear_probe_trace_event(&pkgs[i].tevs[j]); | 1633 | clear_probe_trace_event(&pkgs[i].tevs[j]); |
1634 | free(pkgs[i].tevs); | ||
1635 | } | ||
1636 | free(pkgs); | ||
1632 | 1637 | ||
1633 | return ret; | 1638 | return ret; |
1634 | } | 1639 | } |