spl: NULL check variable before dereference

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>
This commit is contained in:
Andrew Goodbody
2025-07-18 13:19:54 +01:00
committed by Tom Rini
parent 808d4bc2bd
commit ae409a84e7

View 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)