[U-Boot] [PATCH] core: of_addr: Correct the size type of of_get_address to fdt_size_t

Eugeniu Rosca erosca at de.adit-jv.com
Mon Aug 19 10:24:57 UTC 2019


Hi Keerthy,

On Wed, Aug 14, 2019 at 03:56:48PM +0530, Keerthy wrote:
> Currently the size parameter is defined as u64 type.
> Correct the size type of of_get_address to fdt_size_t
> so that both 64 bit and 32 bit architectures are taken
> care of.
> 
> The initial bug report:
> https://patchwork.ozlabs.org/patch/1090094/#2212555
> 
> Fixes: e679d03b08fb ("core: ofnode: Add ofnode_get_addr_size_index")
> Reported-by: Eugeniu Rosca <rosca.eugeniu at gmail.com>
> Tested-by: Eugeniu Rosca <rosca.eugeniu at gmail.com> 
> Signed-off-by: Keerthy <j-keerthy at ti.com>
> ---
> 
> Changes from RFT:
> 
>   * Fixed a typo in the commit log.
>   * Added Reported-by: Eugeniu Rosca <rosca.eugeniu at gmail.com>
> 	  Tested-by: Eugeniu Rosca <rosca.eugeniu at gmail.com>
> 
>  drivers/core/of_addr.c | 4 ++--
>  drivers/core/ofnode.c  | 2 +-
>  include/dm/of_addr.h   | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c
> index 4e256d9926..812a400b19 100644
> --- a/drivers/core/of_addr.c
> +++ b/drivers/core/of_addr.c
> @@ -122,7 +122,7 @@ static void dev_count_cells(const struct device_node *np, int *nap, int *nsp)
>  }
>  
>  const __be32 *of_get_address(const struct device_node *dev, int index,
> -			     u64 *size, unsigned int *flags)
> +			     fdt_size_t *size, unsigned int *flags)

I took some time to also review the changes in addition to testing.

I can see that, since its inception in Linux [1], of_get_address() used
'u64*' type for its 'size' argument. That's still valid in v5.3-rc5.
So, it looks to me that with this patch we diverge from Linux.

I would barely think that the ASAN issue being fixed in this patch
exists in Linux, since the latter receives much more KASAN-enabled
testing on regular basis.

Do you foresee any alternative fix w/o diverging from Linux?

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=22ae782f86b7

-- 
Best Regards,
Eugeniu.


More information about the U-Boot mailing list