Add return value check of opendir in do_one_cpu Signed-off-by: qinyu <qinyu32@huawei.com>
40 lines
929 B
Diff
40 lines
929 B
Diff
From 47f0f26d415b8a1fb2e1d04a39f27b1e4843e7b6 Mon Sep 17 00:00:00 2001
|
|
From: hejingxian 00273181 <hejingxian@huawei.com>
|
|
Date: Fri, 9 Apr 2021 13:32:08 +0800
|
|
Subject: [PATCH] Add return value check of opendir in do_one_cpu
|
|
|
|
Reference:https://github.com/Irqbalance/irqbalance/commit/47f0f26d415b8a1fb2e1d04a39f27b1e4843e7b6
|
|
Conflict:NA
|
|
---
|
|
cputree.c | 7 ++++---
|
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/cputree.c b/cputree.c
|
|
index a8dba73..e4695f2 100644
|
|
--- a/cputree.c
|
|
+++ b/cputree.c
|
|
@@ -366,7 +366,7 @@ static void do_one_cpu(char *path)
|
|
struct topo_obj *node;
|
|
|
|
dir = opendir(path);
|
|
- do {
|
|
+ while (dir) {
|
|
entry = readdir(dir);
|
|
if (!entry)
|
|
break;
|
|
@@ -379,8 +379,9 @@ static void do_one_cpu(char *path)
|
|
break;
|
|
}
|
|
}
|
|
- } while (entry);
|
|
- closedir(dir);
|
|
+ }
|
|
+ if (dir)
|
|
+ closedir(dir);
|
|
|
|
/*
|
|
* In case of multiple NUMA nodes within a CPU package,
|
|
--
|
|
2.23.0
|
|
|