Skip to contentSkip to conversation

libfdt: Don't mask fdt_get_name() returned error

PATCH Applied Pierre-Clément Tosi 2 participants 2 messages Jul 29, 2022 – Jul 30, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfdt: Don't mask fdt_get_name() returned error

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")
---
 libfdt/fdt_check.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
libfdt/fdt_check.c +4 -1
index 71390ee..a21ebbc 100644
@@ -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;
Signature · 1 line
2.37.1.455.g008518b4e5-goog

A message that is not in the archive (sent off-list or not yet received): 20220729130019.804288-1-ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org

Applied
#2 lore raw
Quoted 6 lines · Pierre-Clément Tosi

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

Applied, thanks.

Quoted 20 lines
---
 libfdt/fdt_check.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
libfdt/fdt_check.c +4 -1
index 71390ee..a21ebbc 100644
@@ -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;
Signature · 4 lines
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