]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/of/of_numa.c
of, numa: Validate some distance map rules
[mirror_ubuntu-bionic-kernel.git] / drivers / of / of_numa.c
index 2db1f7a04baf01af9c9707d9f8c3a9fdb0a5b5f8..0b29ee9ee8c34219137962eb7cab69c8d727a531 100644 (file)
@@ -126,9 +126,14 @@ static int __init of_numa_parse_distance_map_v1(struct device_node *map)
                distance = of_read_number(matrix, 1);
                matrix++;
 
+               if ((nodea == nodeb && distance != LOCAL_DISTANCE) ||
+                   (nodea != nodeb && distance <= LOCAL_DISTANCE)) {
+                       pr_err("Invalid distance[node%d -> node%d] = %d\n",
+                              nodea, nodeb, distance);
+                       return -EINVAL;
+               }
+
                numa_set_distance(nodea, nodeb, distance);
-               pr_debug("distance[node%d -> node%d] = %d\n",
-                        nodea, nodeb, distance);
 
                /* Set default distance of node B->A same as A->B */
                if (nodeb > nodea)