[PATCH 1/1] boot: boot_flow_iter_set() called with uninitialized methods_flag

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sun Jan 7 09:56:07 CET 2024


Some code paths do not initialize methods_flag before using it.
Initialize it to 0 in the definition line.

Addresses-Coverity-ID: ("467057 Uninitialized scalar variable")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 boot/bootflow.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 05484fd5b1..4b32d74fe1 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -241,7 +241,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;
@@ -260,7 +260,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
@@ -302,7 +301,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,
-- 
2.43.0



More information about the U-Boot mailing list