Message ID | 1541671533-111674-1-git-send-email-john.garry@huawei.com |
---|---|
State | Accepted |
Commit | 89c38422e072bb453e3045b8f1b962a344c3edea |
Headers | show |
Series | [v2] of, numa: Validate some distance map rules | expand |
On 08/11/2018 10:05, John Garry wrote: > Currently the NUMA distance map parsing does not validate the distance > table for the distance-matrix rules 1-2 in [1]. > Please disregard this. John
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 35c64a4295e0..fe6b13608e51 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -104,9 +104,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)