[PATCH 4/19] ppc64: unflatten_device_tree() should check if lmb_alloc() fails

Michael Ellerman michael at ellerman.id.au
Tue Jul 26 18:58:39 EST 2005


unflatten_device_tree() doesn't check if lmb_alloc() succeeds or not, it
should. All it can do is panic, but at least there's an error message
(assuming you have some sort of console at that point).

---

 arch/ppc64/kernel/prom.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

Index: work/arch/ppc64/kernel/prom.c
===================================================================
--- work.orig/arch/ppc64/kernel/prom.c
+++ work/arch/ppc64/kernel/prom.c
@@ -847,8 +847,13 @@ void __init unflatten_device_tree(void)
 	DBG("  size is %lx, allocating...\n", size);
 
 	/* Allocate memory for the expanded device tree */
-	mem = (unsigned long)abs_to_virt(lmb_alloc(size,
-						   __alignof__(struct device_node)));
+	mem = lmb_alloc(size, __alignof__(struct device_node));
+	if (!mem) {
+		DBG("Couldn't allocate memory with lmb_alloc()!\n");
+		panic("Couldn't allocate memory with lmb_alloc()!\n");
+	}
+	mem = (unsigned long)abs_to_virt(mem);
+
 	DBG("  unflattening...\n", mem);
 
 	/* Second pass, do actual unflattening */



More information about the Linuxppc64-dev mailing list