[PATCH] boot: Ensure method_flags is initialised before use

Tom Rini trini at konsulko.com
Wed Jul 9 02:14:45 CEST 2025


On Fri, Jun 27, 2025 at 11:09:36AM +0100, Andrew Goodbody wrote:

> The local variable method_flags is only assigned to in some of the
> code paths leaving it possibly uninitialised at first use.
> Initialise method_flags at declaration to ensure that it cannot be
> used uninitialised. Also remove now redundant assignments.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>  boot/bootflow.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/boot/bootflow.c b/boot/bootflow.c
> index 4054a966af8..d60e9df6a9d 100644
> --- a/boot/bootflow.c
> +++ b/boot/bootflow.c
> @@ -245,7 +245,7 @@ static int iter_incr(struct bootflow_iter *iter)
>  	if (iter->flags & BOOTFLOWIF_SINGLE_DEV) {
>  		ret = -ENOENT;
>  	} else {
> -		int method_flags;
> +		int method_flags = 0;
>  
>  		ret = 0;
>  		dev = iter->dev;
> @@ -264,7 +264,6 @@ static int iter_incr(struct bootflow_iter *iter)
>  		} else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) &&
>  			   iter->flags & BOOTFLOWIF_SINGLE_MEDIA) {
>  			log_debug("next in single\n");
> -			method_flags = 0;
>  			do {
>  				/*
>  				 * Move to the next bootdev child of this media
> @@ -306,7 +305,6 @@ static int iter_incr(struct bootflow_iter *iter)
>  				}
>  			} else {
>  				ret = bootdev_next_prio(iter, &dev);
> -				method_flags = 0;
>  			}
>  		}
>  		log_debug("ret=%d, dev=%p %s\n", ret, dev,

This leads to failures in CI:
https://source.denx.de/u-boot/u-boot/-/jobs/1195854

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250708/f1cfc7ae/attachment.sig>


More information about the U-Boot mailing list