]> granicus.if.org Git - sysstat/commitdiff
mpstat: Small additional check
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 Mar 2017 08:38:51 +0000 (09:38 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 Mar 2017 08:38:51 +0000 (09:38 +0100)
Make sure node number is not negative.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
mpstat.c

index cfd9296a77aa1babcfcb32dfa74fc9a7a005e63f..ed6ec16e6d8edf9deabd0c75f890c3a27aa7b875 100644 (file)
--- 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;