]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
boot: Ensure method_flags is initialised before use
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Wed, 9 Jul 2025 11:49:09 +0000 (12:49 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 16 Jul 2025 16:56:28 +0000 (10:56 -0600)
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@linaro.org>
boot/bootflow.c

index 4054a966af83a3735c89a9d4af4d29e552af7f54..d79f303486df788df10ceb15bb3e0944ccb79c32 100644 (file)
@@ -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
@@ -296,6 +295,7 @@ static int iter_incr(struct bootflow_iter *iter)
                                        log_debug("looking for next device %s: %s\n",
                                                  iter->dev->name,
                                                  dev ? dev->name : "<none>");
+                                       method_flags = BOOTFLOW_METHF_SINGLE_UCLASS;
                                } else {
                                        dev = NULL;
                                }
@@ -306,7 +306,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,