irqbalance/free-the-memory-when-getline-fail-in-add_one_node.patch
2019-11-19 14:11:38 +08:00

36 lines
875 B
Diff

From 0f7965c9cc3963c4dbfa7b61820ff973ef5da539 Mon Sep 17 00:00:00 2001
From: liuchao173 <liuchao173@huawei.com>
Date: Thu, 7 Nov 2019 09:22:15 +0000
Subject: [PATCH 3/8] backport: free the memory when getline() fail in
add_one_node()
when getline() fail, the memory still need to be freed.
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
numa.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/numa.c b/numa.c
index f0b1a98..542e1f4 100644
--- a/numa.c
+++ b/numa.c
@@ -74,12 +74,11 @@ static void add_one_node(const char *nodename)
cpus_clear(new->mask);
} else {
ret = getline(&cpustr, &blen, f);
- if (ret <= 0) {
+ if (ret <= 0)
cpus_clear(new->mask);
- } else {
+ else
cpumask_parse_user(cpustr, ret, new->mask);
- free(cpustr);
- }
+ free(cpustr);
}
fclose(f);
new->obj_type = OBJ_TYPE_NODE;
--
2.19.1