]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: Correct error return value in mrccache_get_region()
authorSimon Glass <sjg@chromium.org>
Sun, 2 Feb 2020 20:37:06 +0000 (13:37 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 5 Mar 2020 10:19:04 +0000 (18:19 +0800)
This function doesn't use uclass_find_first_device() correctly. Add a
check that the device is found so we don't try to read properties from a
NULL device.

The fixes booting on minnoxmax.

Fixes: 87f1084a630 ("x86: Adjust mrccache_get_region() to use livetree")
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/x86/lib/mrccache.c

index 8914960226dcbdf5dc90ebc79e2342881d437bea..d1c44f290c467e21ca1adb6f5469ba799f67668f 100644 (file)
@@ -241,6 +241,8 @@ int mrccache_get_region(enum mrc_type_t type, struct udevice **devp,
         * memory map cannot be read.
         */
        ret = uclass_find_first_device(UCLASS_SPI_FLASH, &dev);
+       if (!ret && !dev)
+               ret = -ENODEV;
        if (ret)
                return log_msg_ret("Cannot find SPI flash\n", ret);
        ret = dm_spi_get_mmap(dev, &map_base, &map_size, &offset);