Skip to content

Commit 9592032

Browse files
mpepaulusmack
authored andcommitted
[PATCH] ppc64: unflatten_device_tree() should check if lmb_alloc() fails
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). Signed-off-by: Michael Ellerman <[email protected]> arch/ppc64/kernel/prom.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) Signed-off-by: Paul Mackerras <[email protected]>
1 parent 145ec7d commit 9592032

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/ppc64/kernel/prom.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,13 @@ void __init unflatten_device_tree(void)
950950
DBG(" size is %lx, allocating...\n", size);
951951

952952
/* Allocate memory for the expanded device tree */
953-
mem = (unsigned long)abs_to_virt(lmb_alloc(size + 4,
954-
__alignof__(struct device_node)));
953+
mem = lmb_alloc(size + 4, __alignof__(struct device_node));
954+
if (!mem) {
955+
DBG("Couldn't allocate memory with lmb_alloc()!\n");
956+
panic("Couldn't allocate memory with lmb_alloc()!\n");
957+
}
958+
mem = (unsigned long)abs_to_virt(mem);
959+
955960
((u32 *)mem)[size / 4] = 0xdeadbeef;
956961

957962
DBG(" unflattening...\n", mem);

0 commit comments

Comments
 (0)