summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lmb.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/lmb.c b/lib/lmb.c
index 98078b4..6390d63 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -245,6 +245,11 @@ static unsigned long lmb_align_down(unsigned long addr, unsigned long size)
return addr & ~(size - 1);
}
+static unsigned long lmb_align_up(unsigned long addr, unsigned long size)
+{
+ return (addr + (size - 1)) & ~(size - 1);
+}
+
unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
unsigned long max_addr)
{
@@ -281,7 +286,8 @@ unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
if (i < 0)
return 0;
- lmb_add_region(&lmb.reserved, base, size);
+ if (lmb_add_region(&lmb.reserved, base, lmb_align_up(size, align)) < 0)
+ return 0;
return base;
}
OpenPOWER on IntegriCloud