]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spl: NULL check variable before dereference
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 18 Jul 2025 12:19:54 +0000 (13:19 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 29 Jul 2025 19:12:12 +0000 (13:12 -0600)
In boot_from_devices the variable loader is not NULL checked after
assignment and before first use but later code does check it for NULL.
Add a NULL check before first use.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
common/spl/spl.c

index d8e26605d20f4ad732942807ccec8908e2471ddc..ed443c645a7b99a8f24a6e42f9df6b219be65ec6 100644 (file)
@@ -634,7 +634,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
                if (CONFIG_IS_ENABLED(SHOW_ERRORS))
                        ret = -ENXIO;
                for (loader = drv; loader != drv + n_ents; loader++) {
-                       if (bootdev != loader->boot_device)
+                       if (loader && bootdev != loader->boot_device)
                                continue;
                        if (!CONFIG_IS_ENABLED(SILENT_CONSOLE)) {
                                if (loader)