In machine__create_modules() the 'path' char array
was used in a call to symbol__restricted_filename()
without always being populated.

Signed-off-by: Adrian Hunter <adrian.hun...@intel.com>
---
 tools/perf/util/machine.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 933d14f..1ae917c 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -782,20 +782,17 @@ static int machine__create_modules(struct machine 
*machine)
        size_t n;
        FILE *file;
        struct map *map;
-       const char *modules;
        char path[PATH_MAX];
 
        if (machine__is_default_guest(machine))
-               modules = symbol_conf.default_guest_modules;
-       else {
-               sprintf(path, "%s/proc/modules", machine->root_dir);
-               modules = path;
-       }
+               strncpy(path, symbol_conf.default_guest_modules, PATH_MAX);
+       else
+               snprintf(path, PATH_MAX, "%s/proc/modules", machine->root_dir);
 
        if (symbol__restricted_filename(path, "/proc/modules"))
                return -1;
 
-       file = fopen(modules, "r");
+       file = fopen(path, "r");
        if (file == NULL)
                return -1;
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to