[PATCH 04/10] bootchooser: use a globalvar scope for its bootargs
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Nov 11 23:49:18 PST 2026
On 10/30/26 11:54, Sascha Hauer wrote:
> bootchooser passes the active target to the Kernel in
> global.linux.bootargs.bootchooser and sets it to an empty value again
> after booting failed. The variable is never removed though, so it stays
> around with an empty value after the first boot attempt.
>
> Use a globalvar scope instead, which removes the variable again and
> also reverts any other boot related globalvars changed while booting
> the target.
>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> common/bootchooser.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/common/bootchooser.c b/common/bootchooser.c
> index 2a75dfdcc8..2049425ab3 100644
> --- a/common/bootchooser.c
> +++ b/common/bootchooser.c
> @@ -6,6 +6,7 @@
> #define pr_fmt(fmt) "bootchooser: " fmt
>
> #include <bootchooser.h>
> +#include <boot.h>
> #include <environment.h>
> #include <globalvar.h>
> #include <magicvar.h>
> @@ -846,6 +847,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
> struct bootentries *entries;
> struct bootentry *entry;
> struct bootchooser_target *target;
> + struct globalvar_scope *scope = NULL;
> int ret = 0;
>
> entries = bootentries_alloc();
> @@ -857,6 +859,8 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
> goto out;
> }
>
> + scope = boot_globalvar_scope_push();
> +
> system = basprintf("bootchooser.active=%s", target->name);
> globalvar_add_simple("linux.bootargs.bootchooser", system);
> free(system);
> @@ -887,7 +891,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain,
>
> *tryagain = 1;
> out:
> - globalvar_set_match("linux.bootargs.bootchooser", NULL);
> + globalvar_scope_pop(scope);
>
> bootentries_free(entries);
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list