LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: linuxppc-dev@ozlabs.org
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4]: [LMB]: Fix bug in __lmb_alloc_base().
Date: Wed, 13 Feb 2008 17:10:35 -0800 (PST) [thread overview]
Message-ID: <20080213.171035.249149650.davem@davemloft.net> (raw)
[LMB]: Fix bug in __lmb_alloc_base().
We need to check lmb_add_region() for errors, it can run out
of regions etc.
Also, the size needs to be padded to the given alignment
or else the lmb.reserved regions don't get expanded and
instead we get tons of holes and eventually run out of
regions prematurely.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
lib/lmb.c | 8 +++++++-
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;
}
--
1.5.4.29.gb828fe
reply other threads:[~2008-02-14 1:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080213.171035.249149650.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=sparclinux@vger.kernel.org \
--subject='Re: [PATCH 2/4]: [LMB]: Fix bug in __lmb_alloc_base().' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).