From b6f0c6ea70b8142593b5fbf94ce587b2c87f4b32 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 11 Mar 2017 09:38:51 +0100 Subject: [PATCH] mpstat: Small additional check Make sure node number is not negative. Signed-off-by: Sebastien GODARD --- mpstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpstat.c b/mpstat.c index cfd9296..ed6ec16 100644 --- a/mpstat.c +++ b/mpstat.c @@ -300,7 +300,7 @@ int get_node_placement(int cpu_nr, int cpu_per_node[], int cpu2node[]) if (!strncmp(drd->d_name, "node", 4) && isdigit(drd->d_name[4])) { node = atoi(drd->d_name + 4); - if (node >= cpu_nr) { + if ((node >= cpu_nr) || (node < 0)) { /* Assume we cannot have more nodes than CPU */ closedir(dir); return -1; -- 2.49.0