
From: Thierry Reding treding@nvidia.com
The fdtdec_get_pci_addr() implementation uses fdt_addr_to_cpu() to read cells from an FDT blob. That is wrong because cells are always 32 bits wide, irrespective of the architecture's address bus width, which does not apply to fdt_addr_t.
Besides reading the wrong results, this can also cause aborts on 64-bit architectures that don't allow unaligned accesses to memory. Fix this by using fdt32_to_cpu() to read the cells instead.
Cc: Hanna Hawa hannah@marvell.com Cc: Simon Glass sjg@chromium.org Signed-off-by: Thierry Reding treding@nvidia.com --- lib/fdtdec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fd244440381e..c26b06f390b8 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -162,13 +162,13 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
for (i = 0; i < num; i++) { debug("pci address #%d: %08lx %08lx %08lx\n", i, - (ulong)fdt_addr_to_cpu(cell[0]), - (ulong)fdt_addr_to_cpu(cell[1]), - (ulong)fdt_addr_to_cpu(cell[2])); + (ulong)fdt32_to_cpu(cell[0]), + (ulong)fdt32_to_cpu(cell[1]), + (ulong)fdt32_to_cpu(cell[2])); if ((fdt_addr_to_cpu(*cell) & type) == type) { - addr->phys_hi = fdt_addr_to_cpu(cell[0]); - addr->phys_mid = fdt_addr_to_cpu(cell[1]); - addr->phys_lo = fdt_addr_to_cpu(cell[2]); + addr->phys_hi = fdt32_to_cpu(cell[0]); + addr->phys_mid = fdt32_to_cpu(cell[1]); + addr->phys_lo = fdt32_to_cpu(cell[2]); break; } else { cell += (FDT_PCI_ADDR_CELLS +