From 121696c957d741d17125f5416d1210b11ef8afdd Mon Sep 17 00:00:00 2001 From: Mike Looijmans Date: Tue, 30 Jan 2024 15:26:56 +0100 Subject: [PATCH] fsl-layerscape/soc.c: do not destroy bootcmd environment When an XXX_BOOTCOMMAND isn't defined, the result is that bootcmd is set to some random memory content. Fix it so that the function does nothing in that case and leaves the bootcmd environment unmodified. Signed-off-by: Mike Looijmans Reviewed-by: Dan Carpenter --- arch/arm/cpu/armv8/fsl-layerscape/soc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c index 3bfdc3f774..4c61d28c20 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c @@ -811,6 +811,8 @@ __weak int fsl_setenv_bootcmd(void) enum boot_src src = get_boot_src(); char bootcmd_str[MAX_BOOTCMD_SIZE]; + bootcmd_str[0] = 0; + switch (src) { #ifdef IFC_NOR_BOOTCOMMAND case BOOT_SOURCE_IFC_NOR: @@ -859,6 +861,9 @@ __weak int fsl_setenv_bootcmd(void) break; } + if (!bootcmd_str[0]) + return 0; + ret = env_set("bootcmd", bootcmd_str); if (ret) { printf("Failed to set bootcmd: ret = %d\n", ret); -- 2.39.5