[PATCH] xilinx: Free memory when variable is saved in boot_targets_setup()

Michal Simek michal.simek at amd.com
Wed Apr 16 13:35:57 CEST 2025



On 4/10/25 09:38, Michal Simek wrote:
> When boot_targets variable is saved there is no reason to keep string in
> malloc area that's why free it. This change is already done in ZynqMP code.
> 
> Signed-off-by: Michal Simek <michal.simek at amd.com>
> ---
> 
>   board/amd/versal2/board.c   | 3 ++-
>   board/xilinx/versal/board.c | 1 +
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
> index aea3bf022600..ee0dc3487831 100644
> --- a/board/amd/versal2/board.c
> +++ b/board/amd/versal2/board.c
> @@ -1,7 +1,7 @@
>   // SPDX-License-Identifier: GPL-2.0
>   /*
>    * Copyright (C) 2021 - 2022, Xilinx, Inc.
> - * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc.
> + * Copyright (C) 2022 - 2025, Advanced Micro Devices, Inc.
>    *
>    * Michal Simek <michal.simek at amd.com>
>    */
> @@ -307,6 +307,7 @@ static int boot_targets_setup(void)
>   				env_targets ? env_targets : "");
>   
>   		env_set("boot_targets", new_targets);
> +		free(new_targets);
>   	}
>   
>   	return 0;
> diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
> index 6c4a2f5ead62..de53657b0c4e 100644
> --- a/board/xilinx/versal/board.c
> +++ b/board/xilinx/versal/board.c
> @@ -282,6 +282,7 @@ static int boot_targets_setup(void)
>   				env_targets ? env_targets : "");
>   
>   		env_set("boot_targets", new_targets);
> +		free(new_targets);
>   	}
>   
>   	return 0;

Applied.
M


More information about the U-Boot mailing list