]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
xilinx: Free memory when variable is saved in boot_targets_setup()
authorMichal Simek <michal.simek@amd.com>
Thu, 10 Apr 2025 07:38:51 +0000 (09:38 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 16 Apr 2025 11:44:44 +0000 (13:44 +0200)
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@amd.com>
Link: https://lore.kernel.org/r/fa10fc22193a1a23258466056b3d02f7496fccfe.1744270729.git.michal.simek@amd.com
board/amd/versal2/board.c
board/xilinx/versal/board.c

index aea3bf022600798c62705f9432fdb09fb339cf33..ee0dc3487831212b9be9f6addf8d7e364e2af365 100644 (file)
@@ -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@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;
index f0ac3fbadb17b16938165d25b0041cca068a6b9e..9371c30ea2751c51b25451bd8cc8223f12b631a2 100644 (file)
@@ -283,6 +283,7 @@ static int boot_targets_setup(void)
                                env_targets ? env_targets : "");
 
                env_set("boot_targets", new_targets);
+               free(new_targets);
        }
 
        return 0;