numactl/0001-Fixed-segfault-when-no-node-could-be-found-in-sysfs-.patch

50 lines
1.2 KiB
Diff
Raw Normal View History

From a60b4ae108d7853f604e2d75147f6175ba908dfd Mon Sep 17 00:00:00 2001
From: Julian Wolf <juwolf@suse.com>
Date: Fri, 13 Jun 2014 14:24:36 +0200
Subject: [PATCH] Fixed segfault when no node could be found in sysfs
bnc#872922
---
distance.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/distance.c b/distance.c
index 4a26972..84affa3 100755
--- a/distance.c
+++ b/distance.c
@@ -57,6 +57,7 @@ static int read_distance_table(void)
int maxnode = numa_max_node() + 1;
int *table = NULL;
int err = -1;
+ int cnt = 0;
for (nd = 0;; nd++) {
char fn[100];
@@ -70,6 +71,8 @@ static int read_distance_table(void)
continue;
else
break;
+ }else {
+ cnt++;
}
len = getdelim(&line, &linelen, '\n', dfh);
fclose(dfh);
@@ -87,12 +90,12 @@ static int read_distance_table(void)
parse_numbers(line, table + nd * maxnode);
}
free(line);
- if (err) {
+ if (err || !cnt) {
numa_warn(W_distance,
"Cannot parse distance information in sysfs: %s",
strerror(errno));
free(table);
- return err;
+ return -1;
}
/* Update the global table pointer. Race window here with
other threads, but in the worst case we leak one distance
--
1.8.1.4