[PATCH] common: spl: ram: fix return code

Stefan Roese sr at denx.de
Mon Dec 12 09:06:59 CET 2022


On 12/12/22 09:03, Nikita Shubin wrote:
> From: Nikita Shubin <n.shubin at yadro.com>
> 
> Instead of always retuning success, return actual result of
> load_simple_fit_image or spl_parse_image_header, otherwise we
> might end up jumping on uninitialized spl_image->entry_point.
> 
> Signed-off-by: Nikita Shubin <n.shubin at yadro.com>
> ---
>   common/spl/spl_ram.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
> index d64710878c..56c7598c4b 100644
> --- a/common/spl/spl_ram.c
> +++ b/common/spl/spl_ram.c
> @@ -42,12 +42,13 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
>   			      struct spl_boot_device *bootdev)
>   {
>   	struct image_header *header;
> +	int ret;
>   
>   	header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
>   
>   	if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
>   		unsigned long addr = (unsigned long)header;
> -		int ret = image_pre_load(addr);
> +		ret = image_pre_load(addr);
>   
>   		if (ret)
>   			return ret;
> @@ -68,7 +69,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
>   		debug("Found FIT\n");
>   		load.bl_len = 1;
>   		load.read = spl_ram_load_read;
> -		spl_load_simple_fit(spl_image, &load, 0, header);
> +		ret = spl_load_simple_fit(spl_image, &load, 0, header);
>   	} else {
>   		ulong u_boot_pos = spl_get_image_pos();
>   
> @@ -89,10 +90,10 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
>   		}
>   		header = (struct image_header *)map_sysmem(u_boot_pos, 0);
>   
> -		spl_parse_image_header(spl_image, bootdev, header);
> +		ret = spl_parse_image_header(spl_image, bootdev, header);
>   	}
>   
> -	return 0;
> +	return ret;
>   }
>   #if CONFIG_IS_ENABLED(RAM_DEVICE)
>   SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM, spl_ram_load_image);

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan


More information about the U-Boot mailing list