[PATCH 1/1] bootflow: always initialize bootflow_iter_set_dev parameters

Nam Cao namcao at linutronix.de
Thu Apr 11 08:52:25 CEST 2024


On 11/Apr/2024 Heinrich Schuchardt wrote:
> method_flags may be passed uninitialized to bootflow_iter_set_dev()
> if dev is not NULL.
> 
> Always initialize method_flags.
> 
> Addresses-Coverity-ID: 467057 Uninitialized scalar variable
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>

Reviewed-by: Nam Cao <namcao at linutronix.de>

> ---
>  boot/bootflow.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/boot/bootflow.c b/boot/bootflow.c
> index 68bf99329ab..f659a414c79 100644
> --- a/boot/bootflow.c
> +++ b/boot/bootflow.c
> @@ -244,7 +244,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;
> @@ -263,7 +263,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
> @@ -305,7 +304,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,



More information about the U-Boot mailing list