[PATCH 1/1] starfive: avoid NULL dereference in fdt_check_header()

E Shattow e at freeshell.de
Thu Aug 28 23:37:42 CEST 2025



On 8/28/25 06:03, Heinrich Schuchardt wrote:
> If the u-boot.itb read from SD-card is invalid, fdt_check_header() may be

Here is said SD-card, and later is said UART. Is SD-card the only way to
cause this condition?

> called with a NULL pointer.
> 
> This was observed on an StarFive VisionFive Lite when trying to revover the

"This was observed on an StarFive VisionFive 2 Lite when trying to
recover the board via UART."

There is a VisionFive product with JH7100 CPU, we are not that, here.

> board via UART.>
> Add a missing check in the starfive board code.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  board/starfive/visionfive2/spl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
> index 3dfa931b655..fe14b44ce28 100644
> --- a/board/starfive/visionfive2/spl.c
> +++ b/board/starfive/visionfive2/spl.c
> @@ -23,7 +23,8 @@ DECLARE_GLOBAL_DATA_PTR;
>  void spl_perform_fixups(struct spl_image_info *spl_image)
>  {
>  	/* Update the memory size which read from eeprom or DT */
> -	fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
> +	if (spl_image->fdt_addr)
> +		fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
>  }
>  
>  static void jh7110_jtag_init(void)

Commit message sounds confusing to me, code is fine though. Maybe some
debug output print would be helpful in case of failure, since it is a
void function and we have introduced a code path where the fdt fixup is
skipped without warning. Also fine as it is just improve the commit
message please. With that,

Reviewed-by: E Shattow <e at freeshell.de>


More information about the U-Boot mailing list