From: Simon Glass Date: Wed, 25 Sep 2019 14:55:50 +0000 (-0600) Subject: dm: core: Correct bad cast in ofnode_get_addr_size_index() X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=e18c41fca46a33bf76b4664796e3e132dc71c6cb;p=u-boot.git dm: core: Correct bad cast in ofnode_get_addr_size_index() At present this code passes an fdt_addr_t pointer as a u64 pointer which is not safe, since sizeof(fdt_addr_t) may be 4, e.g. with sandbox. Correct this to avoid a stack corruption problem. Fixes: e679d03b08 (core: ofnode: Add ofnode_get_addr_size_index) Signed-off-by: Simon Glass Reviewed-by: Bin Meng [bmeng: correct one typo in the commit message] Signed-off-by: Bin Meng --- diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 5d47eccf1d..297f0a0c7c 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -261,12 +261,15 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) if (ofnode_is_np(node)) { const __be32 *prop_val; + u64 size64; uint flags; - prop_val = of_get_address(ofnode_to_np(node), index, - (u64 *)size, &flags); + prop_val = of_get_address(ofnode_to_np(node), index, &size64, + &flags); if (!prop_val) return FDT_ADDR_T_NONE; + if (size) + *size = size64; ns = of_n_size_cells(ofnode_to_np(node));