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

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Thu Apr 11 00:12:06 CEST 2024


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>
---
 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,
-- 
2.43.0



More information about the U-Boot mailing list