Signed-off-by: Bobo Du <dubo163@xxxxxxx> --- cputree.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cputree.c b/cputree.c index 91c6111..67acc93 100644 --- a/cputree.c +++ b/cputree.c @@ -380,21 +380,23 @@ static void do_one_cpu(char *path) struct topo_obj *node; dir = opendir(path); - do { - entry = readdir(dir); - if (!entry) - break; - if (strncmp(entry->d_name, "node", 4) == 0) { - char *end; - int num; - num = strtol(entry->d_name + 4, &end, 10); - if (!*end && num >= 0) { - nodeid = num; + if (dir) { + do { + entry = readdir(dir); + if (!entry) break; + if (strncmp(entry->d_name, "node", 4) == 0) { + char *end; + int num; + num = strtol(entry->d_name + 4, &end, 10); + if (!*end && num >= 0) { + nodeid = num; + break; + } } - } - } while (entry); - closedir(dir); + } while (entry); + closedir(dir); + } /* * In case of multiple NUMA nodes within a CPU package, -- 2.14.1 _______________________________________________ irqbalance mailing list irqbalance@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/irqbalance