diff mbox series

[U-Boot,v3,007/108] dm: core: Fix offset_to_ofnode() with invalid offset

Message ID 20191021033322.217715-8-sjg@chromium.org
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Oct. 21, 2019, 3:31 a.m. UTC
If the offset is -1 this function correct sets up a null ofnode. But if
the offset is any other negative number (e.g. an FDT_ERR) then it does the
wrong thing.

Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 include/dm/ofnode.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bin Meng Oct. 28, 2019, 4:45 a.m. UTC | #1
Hi Simon,

On Mon, Oct 21, 2019 at 11:33 AM Simon Glass <sjg@chromium.org> wrote:
>
> If the offset is -1 this function correct sets up a null ofnode. But if

correctly?

> the offset is any other negative number (e.g. an FDT_ERR) then it does the

FDT_ERR is -1. So probably another error number?

> wrong thing.

>
> Fix it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  include/dm/ofnode.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index 5c4cbf09986..4282169706c 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -118,7 +118,7 @@ static inline ofnode offset_to_ofnode(int of_offset)
>         if (of_live_active())
>                 node.np = NULL;
>         else
> -               node.of_offset = of_offset;
> +               node.of_offset = of_offset >= 0 ? of_offset : -1;
>
>         return node;
>  }
> --

Regards,
Bin
diff mbox series

Patch

diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 5c4cbf09986..4282169706c 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -118,7 +118,7 @@  static inline ofnode offset_to_ofnode(int of_offset)
 	if (of_live_active())
 		node.np = NULL;
 	else
-		node.of_offset = of_offset;
+		node.of_offset = of_offset >= 0 ? of_offset : -1;
 
 	return node;
 }