diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 8b213482e564..baf855e596c2 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -340,9 +340,10 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid) if (!seen) seen = strlist__new(NULL, NULL); - if (!strlist__has_entry(seen, path)) { + if (!seen || !strlist__has_entry(seen, path)) { pr_err("Can't access file %s\n", path); - strlist__add(seen, path); + if (seen) + strlist__add(seen, path); } machine = NULL; goto out;