aboutsummaryrefslogtreecommitdiff
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2007-05-15 01:39:05 -0700
committerChris Wright <chrisw@sous-sol.org>2007-05-23 14:32:51 -0700
commitb4bcec01273f41732e01b89e101ac0afe8759485 (patch)
tree94d90d62b44e8d3c70c1b3d73ae17e91e16ee305 /arch/sparc64
parent38112b91c85831aa199174b9f52d6f90fe37307a (diff)
[PATCH] SPARC64: Fix recursion in PROM tree building.
Use iteration for scanning of PROM node siblings. Based upon a patch by Greg Onufer, who found this bug. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/prom.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 0917c24c4f0..3494adf673b 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -1555,10 +1555,21 @@ static struct device_node * __init create_node(phandle node, struct device_node
static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
{
+ struct device_node *ret = NULL, *prev_sibling = NULL;
struct device_node *dp;
- dp = create_node(node, parent);
- if (dp) {
+ while (1) {
+ dp = create_node(node, parent);
+ if (!dp)
+ break;
+
+ if (prev_sibling)
+ prev_sibling->sibling = dp;
+
+ if (!ret)
+ ret = dp;
+ prev_sibling = dp;
+
*(*nextp) = dp;
*nextp = &dp->allnext;
@@ -1567,10 +1578,10 @@ static struct device_node * __init build_tree(struct device_node *parent, phandl
dp->child = build_tree(dp, prom_getchild(node), nextp);
- dp->sibling = build_tree(parent, prom_getsibling(node), nextp);
+ node = prom_getsibling(node);
}
- return dp;
+ return ret;
}
void __init prom_build_devicetree(void)