diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7acc03e8f3b2eabaf7bdb5620ea463ba6cacabb5..0b39a48e5110a00dde5fa0408c725730ba5fe8ff 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -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) { @@ -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,