[PATCH] Fix segfault in read_distance_table when no NUMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Debian bug #712692 reported a segfault on systems with no numa info.
In this case, read_distance_table would exit with "0" which was not
picked up as an error by numa_distance(), leading to a dereference of
distance_table.

Signed-off-by: Ian Wienand <ian@xxxxxxxxxxx>
---
 distance.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/distance.c b/distance.c
index 4a26972..ec423c4 100755
--- a/distance.c
+++ b/distance.c
@@ -58,15 +58,13 @@ static int read_distance_table(void)
 	int *table = NULL;
 	int err = -1;
 
-	for (nd = 0;; nd++) {
+	for (nd = 0; nd<maxnode; nd++) {
 		char fn[100];
 		FILE *dfh;
 		sprintf(fn, "/sys/devices/system/node/node%d/distance", nd);
 		dfh = fopen(fn, "r");
 		if (!dfh) {
 			if (errno == ENOENT)
-				err = 0;
-			if (!err && nd<maxnode)
 				continue;
 			else
 				break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux