[PATCH] of: Fix endless loop in of_add_memory

Sascha Hauer s.hauer at pengutronix.de
Wed Aug 14 03:35:28 EDT 2013


of_add_memory is stuck in an endless loop when a memory bank with zero
size is passed. Fix this.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/of/base.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 34a06c2..33dfd5a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1555,8 +1555,11 @@ int of_add_memory(struct device_node *node, bool dump)
 		return -ENXIO;
 
 	while (!of_address_to_resource(node, n, &res)) {
-		if (!resource_size(&res))
+		if (!resource_size(&res)) {
+			n++;
 			continue;
+		}
+
 		of_add_memory_bank(node, dump, n,
 				res.start, resource_size(&res));
 		n++;
-- 
1.8.4.rc2




More information about the barebox mailing list