]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fsl-layerscape/soc.c: do not destroy bootcmd environment
authorMike Looijmans <mike.looijmans@topic.nl>
Tue, 30 Jan 2024 14:26:56 +0000 (15:26 +0100)
committerPeng Fan <peng.fan@nxp.com>
Thu, 8 Feb 2024 02:45:32 +0000 (10:45 +0800)
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 <mike.looijmans@topic.nl>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
arch/arm/cpu/armv8/fsl-layerscape/soc.c

index 3bfdc3f7743110961b96eab0c74c2e2d29d86df5..4c61d28c20f004960b530815aecf8c1eac58895b 100644 (file)
@@ -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);