Skip to contentSkip to conversation

powerpc/boot: Fix simpleboot CPU node lookup check

PATCH Applied Thorsten Blum 3 participants 7 messages Jul 2 – Jul 30 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 powerpc/boot: Fix simpleboot CPU node lookup check

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes d2477b5cc8ca ("[POWERPC] bootwrapper: Add a firmware-independent simpleboot target.")
---
 arch/powerpc/boot/simpleboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/simpleboot.c +1 -1
index c80691d83880..27591df41e9e 100644
@@ -68,7 +68,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
 	/* finally, setup the timebase */
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 					     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
#1 lore raw

PATCH 2/3 powerpc/boot: Fix treeboot-currituck CPU node lookup check

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes 228d55053397 ("powerpc/47x: Add support for the new IBM currituck platform")
---
 arch/powerpc/boot/treeboot-currituck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/treeboot-currituck.c +1 -1
index d53e8a592f81..5b5363b74f9f 100644
@@ -102,7 +102,7 @@ void platform_init(void)
 
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 	                                     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
reviewer Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] powerpc/boot: Fix treeboot-currituck CPU node lookup check

Quoted 5 lines · Thorsten Blum

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes 228d55053397 ("powerpc/47x: Add support for the new IBM currituck platform")

Looks good to me. Please feel free to add:

Quoted 17 lines
---
 arch/powerpc/boot/treeboot-currituck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/treeboot-currituck.c +1 -1
index d53e8a592f81..5b5363b74f9f 100644
@@ -102,7 +102,7 @@ void platform_init(void)
 
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 	                                     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
#3 lore raw

PATCH 3/3 powerpc/boot: Fix treeboot-akebono CPU node lookup check

In reply to Thorsten Blum

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes 2a2c74b2efcb ("IBM Akebono: Add the Akebono platform")
---
 arch/powerpc/boot/treeboot-akebono.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/treeboot-akebono.c +1 -1
index e3cc2599869c..1b529037480f 100644
@@ -146,7 +146,7 @@ void platform_init(char *userdata)
 
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 					     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
reviewer Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] powerpc/boot: Fix treeboot-akebono CPU node lookup check

Quoted 5 lines · Thorsten Blum

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes 2a2c74b2efcb ("IBM Akebono: Add the Akebono platform")

Looks good to me. Please feel free to add:

Quoted 17 lines
---
 arch/powerpc/boot/treeboot-akebono.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/treeboot-akebono.c +1 -1
index e3cc2599869c..1b529037480f 100644
@@ -146,7 +146,7 @@ void platform_init(char *userdata)
 
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 					     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
reviewer Reviewed-by on v1 1/3
#5 lore raw
In reply to Thorsten Blum
Quoted 5 lines · Thorsten Blum

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Fixes d2477b5cc8ca ("[POWERPC] bootwrapper: Add a firmware-independent simpleboot target.")

yup, if it cannot find the node, then it should return a negative error code, since cpu node is never the root node. The same thing was anyway properly done for memory device node in the same function few lines before...

	/* Find the memory range */
	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
					     "memory", sizeof("memory"));
	if (node < 0)
		fatal("Cannot find memory node\n");

...but for cpu node, it uses a wrong comparison check.

Looks good to me. Please feel free to add:

Quoted 17 lines
---
 arch/powerpc/boot/simpleboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/simpleboot.c +1 -1
index c80691d83880..27591df41e9e 100644
@@ -68,7 +68,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
 	/* finally, setup the timebase */
 	node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
 					     "cpu", sizeof("cpu"));
-	if (!node)
+	if (node < 0)
 		fatal("Cannot find cpu node\n");
 	timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
 	if (timebase && (size == 4))
maintainer Applied
#6 lore raw
In reply to Thorsten Blum
Quoted 4 lines · Thorsten Blum

fdt_node_offset_by_prop_value() returns a negative error code on failure - fix the check accordingly.

Applied to powerpc/fixes.

[1/3] powerpc/boot: Fix simpleboot CPU node lookup check

      https://git.kernel.org/powerpc/c/c824ab65685bb119c6c6a3a200b3428c72862d5a
[2/3] powerpc/boot: Fix treeboot-currituck CPU node lookup check
      https://git.kernel.org/powerpc/c/43863f6575d2211e8c5157fefb83ad0ad046aab4
[3/3] powerpc/boot: Fix treeboot-akebono CPU node lookup check
      https://git.kernel.org/powerpc/c/b24fc8278b70a9d27ec801a427ab4de9b769d69a

cheers