Skip to content

Commit

Permalink
perf session: Free cpu_map in perf_session__cpu_bitmap
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ Use goto + err = -1 to do the delete just once, in the normal exit path ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
Stanislav Fomichev authored and acmel committed Jan 20, 2014
1 parent 3415d8b commit 8bac41c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
int perf_session__cpu_bitmap(struct perf_session *session,
const char *cpu_list, unsigned long *cpu_bitmap)
{
int i;
int i, err = -1;
struct cpu_map *map;

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

set_bit(cpu, cpu_bitmap);
}

return 0;
err = 0;

out_delete_map:
cpu_map__delete(map);
return err;
}

void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
Expand Down

0 comments on commit 8bac41c

Please sign in to comment.