diff mbox series

x86: Correct error return value in mrccache_get_region()

Message ID 20200202133701.1.If5436f9437aecc61a230c401597337790bb139df@changeid
State Accepted
Commit 7149d3800558df4b5ba535472c6968ea9b2332c9
Delegated to: Bin Meng
Headers show
Series x86: Correct error return value in mrccache_get_region() | expand

Commit Message

Simon Glass Feb. 2, 2020, 8:37 p.m. UTC
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>
---

 arch/x86/lib/mrccache.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Bin Meng Feb. 3, 2020, 12:44 a.m. UTC | #1
On Mon, Feb 3, 2020 at 4:37 AM Simon Glass <sjg@chromium.org> wrote:
>
> 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>
> ---
>
>  arch/x86/lib/mrccache.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Feb. 20, 2020, 1:05 p.m. UTC | #2
On Mon, Feb 3, 2020 at 8:44 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Mon, Feb 3, 2020 at 4:37 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > 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>
> > ---
> >
> >  arch/x86/lib/mrccache.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index b9420a4cab..288673b0ea 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -240,6 +240,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);