diff options
author | David Ahern <dsahern@gmail.com> | 2012-07-29 22:54:35 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-03 09:35:23 -0400 |
commit | 347ed9903a10179d1cf733d5d77072b283d89da3 (patch) | |
tree | d5d26aedbf34f6d1ce8eb969fa051710f62b1410 /tools/perf/util | |
parent | 56e6f602aa4432f7fe90a0d9ba379b2735b07b6b (diff) |
perf kvm: Use strtol for walking guestmount directory
Only want to process directories under the guestmnount directory that
have a pid as a name (ie, all digits). Other entries in the guestmount
directory should be ignored. There is already a check that requires the
first character of each entry to be a digit, but atoi is used to convert
the directory name to a pid. For example if guestmount contains a
directory with the name 1foo, atoi converts it to a pid of 1 and a
machine is created with a pid of 1. This is wrong; this directory really
should be ignored. Use strtol to do that.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1343616875-6455-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/symbol.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index fe86612afadc..8b63b678e127 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -2875,6 +2875,7 @@ int machines__create_guest_kernel_maps(struct rb_root *machines) | |||
2875 | int i, items = 0; | 2875 | int i, items = 0; |
2876 | char path[PATH_MAX]; | 2876 | char path[PATH_MAX]; |
2877 | pid_t pid; | 2877 | pid_t pid; |
2878 | char *endp; | ||
2878 | 2879 | ||
2879 | if (symbol_conf.default_guest_vmlinux_name || | 2880 | if (symbol_conf.default_guest_vmlinux_name || |
2880 | symbol_conf.default_guest_modules || | 2881 | symbol_conf.default_guest_modules || |
@@ -2891,7 +2892,14 @@ int machines__create_guest_kernel_maps(struct rb_root *machines) | |||
2891 | /* Filter out . and .. */ | 2892 | /* Filter out . and .. */ |
2892 | continue; | 2893 | continue; |
2893 | } | 2894 | } |
2894 | pid = atoi(namelist[i]->d_name); | 2895 | pid = (pid_t)strtol(namelist[i]->d_name, &endp, 10); |
2896 | if ((*endp != '\0') || | ||
2897 | (endp == namelist[i]->d_name) || | ||
2898 | (errno == ERANGE)) { | ||
2899 | pr_debug("invalid directory (%s). Skipping.\n", | ||
2900 | namelist[i]->d_name); | ||
2901 | continue; | ||
2902 | } | ||
2895 | sprintf(path, "%s/%s/proc/kallsyms", | 2903 | sprintf(path, "%s/%s/proc/kallsyms", |
2896 | symbol_conf.guestmount, | 2904 | symbol_conf.guestmount, |
2897 | namelist[i]->d_name); | 2905 | namelist[i]->d_name); |