All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libfdt: Don't mask fdt_get_name() returned error
@ 2022-07-29 13:00 Pierre-Clément Tosi
       [not found] ` <20220729130019.804288-1-ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Pierre-Clément Tosi @ 2022-07-29 13:00 UTC (permalink / raw)
  To: David Gibson
  Cc: Pierre-Clément Tosi,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Mike McTernan

Return the error code from fdt_get_name() (contained in len when the
result is NULL) instead of masking it with FDT_ERR_BADSTRUCTURE.

Fixes: fda71da26e7f ("libfdt: Handle failed get_name() on BEGIN_NODE")
Reported-by: Mike McTernan <mikemcternan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Pierre-Clément Tosi <ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
 libfdt/fdt_check.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libfdt/fdt_check.c b/libfdt/fdt_check.c
index 71390ee..a21ebbc 100644
--- a/libfdt/fdt_check.c
+++ b/libfdt/fdt_check.c
@@ -66,7 +66,10 @@ int fdt_check_full(const void *fdt, size_t bufsize)
 				int len;
 
 				name = fdt_get_name(fdt, offset, &len);
-				if (!name || *name || len)
+				if (!name)
+					return len;
+
+				if (*name || len)
 					return -FDT_ERR_BADSTRUCTURE;
 			}
 			break;
-- 
2.37.1.455.g008518b4e5-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libfdt: Don't mask fdt_get_name() returned error
       [not found] ` <20220729130019.804288-1-ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
@ 2022-07-30  3:52   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2022-07-30  3:52 UTC (permalink / raw)
  To: Pierre-Clément Tosi
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Mike McTernan

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On Fri, Jul 29, 2022 at 02:00:19PM +0100, Pierre-Clément Tosi wrote:
> Return the error code from fdt_get_name() (contained in len when the
> result is NULL) instead of masking it with FDT_ERR_BADSTRUCTURE.
> 
> Fixes: fda71da26e7f ("libfdt: Handle failed get_name() on BEGIN_NODE")
> Reported-by: Mike McTernan <mikemcternan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Pierre-Clément Tosi <ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>

Applied, thanks.

> ---
>  libfdt/fdt_check.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libfdt/fdt_check.c b/libfdt/fdt_check.c
> index 71390ee..a21ebbc 100644
> --- a/libfdt/fdt_check.c
> +++ b/libfdt/fdt_check.c
> @@ -66,7 +66,10 @@ int fdt_check_full(const void *fdt, size_t bufsize)
>  				int len;
>  
>  				name = fdt_get_name(fdt, offset, &len);
> -				if (!name || *name || len)
> +				if (!name)
> +					return len;
> +
> +				if (*name || len)
>  					return -FDT_ERR_BADSTRUCTURE;
>  			}
>  			break;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-30  3:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 13:00 [PATCH] libfdt: Don't mask fdt_get_name() returned error Pierre-Clément Tosi
     [not found] ` <20220729130019.804288-1-ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2022-07-30  3:52   ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.