Clear env vars used in recovery script before and after running it
authorPiotr Dymacz <pepe2k@gmail.com>
Wed, 5 Apr 2017 21:15:48 +0000 (23:15 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Wed, 5 Apr 2017 21:15:48 +0000 (23:15 +0200)
Recovery script uses two variables: a button press time counter (cnt)
and a flag (stop_boot) used later to decide if booting process should be
interrupted.

Clear their values before and after running recovery script as they
could already exist in environment (could be accidentally saved).

u-boot/common/main.c

index 6237d154cda007a80acaa03e8b2b949446063fcf..4a599889f9a037911a221e4696520891c4a3c5e9 100644 (file)
@@ -162,14 +162,25 @@ void main_loop(void)
                gd->flags &= ~(GD_FLG_SILENT);
                #endif
 
+               /*
+                * Always clear values of variables used in recovery script
+                * as they could be accidentally saved before
+                */
+               setenv("stop_boot", NULL);
+               setenv("cnt", NULL);
+
                run_command("run recovery", 0);
 
                /* Should we stop booting after recovery mode? */
                c = getenv("stop_boot");
                stop_boot = c ? (int)simple_strtol(c, NULL, 10) : 0;
 
-               if (stop_boot)
+               if (stop_boot) {
+                       setenv("stop_boot", NULL);
                        bootcmd = NULL;
+               }
+
+               setenv("cnt", NULL);
        }
 #endif /* CONFIG_RECOVERY_MODE */