Skip to content

Commit 8bac41c

Browse files
Stanislav Fomichevacmel
authored andcommitted
perf session: Free cpu_map in perf_session__cpu_bitmap
This method uses a temporary struct cpu_map to figure out the cpus present in the received cpu list in string form, but it failed to free it after returning. Fix it. Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1390217980-22424-3-git-send-email-stfomichev@yandex-team.ru [ Use goto + err = -1 to do the delete just once, in the normal exit path ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 3415d8b commit 8bac41c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/perf/util/session.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
15731573
int perf_session__cpu_bitmap(struct perf_session *session,
15741574
const char *cpu_list, unsigned long *cpu_bitmap)
15751575
{
1576-
int i;
1576+
int i, err = -1;
15771577
struct cpu_map *map;
15781578

15791579
for (i = 0; i < PERF_TYPE_MAX; ++i) {
@@ -1602,13 +1602,17 @@ int perf_session__cpu_bitmap(struct perf_session *session,
16021602
if (cpu >= MAX_NR_CPUS) {
16031603
pr_err("Requested CPU %d too large. "
16041604
"Consider raising MAX_NR_CPUS\n", cpu);
1605-
return -1;
1605+
goto out_delete_map;
16061606
}
16071607

16081608
set_bit(cpu, cpu_bitmap);
16091609
}
16101610

1611-
return 0;
1611+
err = 0;
1612+
1613+
out_delete_map:
1614+
cpu_map__delete(map);
1615+
return err;
16121616
}
16131617

16141618
void perf_session__fprintf_info(struct perf_session *session, FILE *fp,

0 commit comments

Comments
 (0)