Skip to contentSkip to conversation

perf tools: fix crash with invalid CPU list

PATCH In review David Ahern 1 participant 2 messages Nov 13, 2011 – Dec 5, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: fix crash with invalid CPU list

commit 5d67be9 added the option to specify a range of CPUs of interest, but does not catch an invalid CPU list:

$ perf script -c foo
Segmentation fault (core dumped)
---
 tools/perf/util/session.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/util/session.c +4 -0
index 85c1e6b7..0f4555c 100644
@@ -1333,6 +1333,10 @@ int perf_session__cpu_bitmap(struct perf_session *session,
 	}
 
 	map = cpu_map__new(cpu_list);
+	if (map == NULL) {
+		pr_err("Invalid cpu_list\n");
+		return -1;
+	}
 
 	for (i = 0; i < map->nr; i++) {
 		int cpu = map->map[i];
Signature · 1 line
1.7.7.1
#1 lore raw

[tip:perf/urgent] perf session: Fix crash with invalid CPU list

Commit-ID:  47fbe53bef3b219a365ebf3eca949d6cd4c5291c
Gitweb:     http://git.kernel.org/tip/47fbe53bef3b219a365ebf3eca949d6cd4c5291c
Author:     David Ahern <[email protected]>
AuthorDate: Sun, 13 Nov 2011 10:45:27 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 16 Nov 2011 10:02:26 -0200

perf session: Fix crash with invalid CPU list

commit 5d67be9 added the option to specify a range of CPUs of interest, but does not catch an invalid CPU list:

$ perf script -c foo
Segmentation fault (core dumped)
---
 tools/perf/util/session.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
tools/perf/util/session.c +4 -0
index 85c1e6b7..0f4555c 100644
@@ -1333,6 +1333,10 @@ int perf_session__cpu_bitmap(struct perf_session *session,
 	}
 
 	map = cpu_map__new(cpu_list);
+	if (map == NULL) {
+		pr_err("Invalid cpu_list\n");
+		return -1;
+	}
 
 	for (i = 0; i < map->nr; i++) {
 		int cpu = map->map[i];