Devicetree fixes for 4.20-rc:

- Add validation of NUMA distance map to prevent crashes with bad map
 
 - Fix setting of dma_mask
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAlvl/SgQHHJvYmhAa2Vy
 bmVsLm9yZwAKCRD6+121jbxhw2A6EACXS2FKg9KLfzGx41uuKCjFONbWK2m0v2vA
 2L5+hIAnAo0H8JTPn5Nl8vpJyT19s7bdmTHDzfnxbyMPeC3WCn28EjgscuOf2ViY
 JKqbyHVERxpJDG1P4Q7sEd3sDST2Ab65sYn1njldmJ8C9MSnVTXnQVFUEyHEtLfB
 P9kHKuZefb1CXytFG1F80Fe7TqmMm1B0XbfxHFte9l4cDblMPildaoxDp7aXL+pQ
 uvAfFw+UwvqQ+UA6En/ZiN0YLtqI5clm4cuhgzsjp5Wjppo1KNjB+Qrdd5myUoh7
 J18HCox0PH8iR6iJ6RkL8Q+qs6nlOP4gHfWw8bE3SpgeoUn4soe1JGfgvCcFI3ce
 qwuzLgN6FJeszEff+DVq5CmPopKgHGVJ/CGvDToxu/r4smWt5NW6qihGDLsIx1oF
 xsbN+HyXTLzjnjNzAlz8fohdWUwp+NrI2jiuarfvGDbriZhwof1wO9sQdrJZl+ZA
 ff2y0S528Fn3KBHld1HR4jx4glSARkD8oZfoU28L+qNF6rFosklD+EHuXuyb3z0K
 K70nRmZBbvHsozy0bukzN0NOyxIcI1KOtU4hCTCVGNlBnAIwr2iHZnkzCajD7ISS
 w2VZHu8gc4D2psw69kj75ZPuR7FKXRkeoQrOBSleNGa2/5+4LIw3KXisF5eJqt4i
 ////Ait9Ew==
 =FThV
 -----END PGP SIGNATURE-----

Merge tag 'devicetree-fixes-for-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull Devicetree fixes from Rob Herring:

 - Add validation of NUMA distance map to prevent crashes with bad map

 - Fix setting of dma_mask

* tag 'devicetree-fixes-for-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
  of, numa: Validate some distance map rules
  of/device: Really only set bus DMA mask when appropriate
This commit is contained in:
Linus Torvalds 2018-11-09 16:41:58 -06:00
commit aa4330e15c
2 changed files with 10 additions and 3 deletions

View File

@ -149,9 +149,11 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
* set by the driver.
*/
mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1);
dev->bus_dma_mask = mask;
dev->coherent_dma_mask &= mask;
*dev->dma_mask &= mask;
/* ...but only set bus mask if we found valid dma-ranges earlier */
if (!ret)
dev->bus_dma_mask = mask;
coherent = of_dma_is_coherent(np);
dev_dbg(dev, "device is%sdma coherent\n",

View File

@ -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)