[PATCH 03/17] fdt: Correct GPIO name access in fdtdec

Simon Glass sjg at chromium.org
Sun Jan 15 11:47:15 EST 2012


This was missing an fdt32_to_cpu() call so got the name pointer wrong.
If the GPIO module looks at it, this would cause a problem.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 lib/fdtdec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index bcb2343..f7d0c95 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -418,7 +418,7 @@ static int fdtdec_decode_gpios(const void *blob, int node,
 	}
 
 	/* We will use the name to tag the GPIO */
-	name = fdt_string(blob, prop->nameoff);
+	name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
 	cell = (u32 *)prop->data;
 	len /= sizeof(u32) * 3;		/* 3 cells per GPIO record */
 	if (len > max_count) {
@@ -444,6 +444,7 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
 
 	debug("%s: %s\n", __func__, prop_name);
 	gpio->gpio = FDT_GPIO_NONE;
+	gpio->name = NULL;
 	err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
 	return err == 1 ? 0 : err;
 }
-- 
1.7.7.3



More information about the devicetree-discuss mailing list