linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memblock.c: Correctly check whether to trim a block
@ 2012-03-29  2:25 Laura Abbott
  2012-03-29  4:01 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Laura Abbott @ 2012-03-29  2:25 UTC (permalink / raw)
  To: linux-mm, benh, yinghai; +Cc: linux-kernel, linux-arm-msm, Laura Abbott

Currently in __memblock_remove, the check to trim the top of
a block off only checks if the requested base is less than the
memblock end. If the end of the requested region is equal to
the start of a memblock, this will incorrectly try to remove
the block, possibly causing an integer underflow:

   ---------------------------------------
   |                    |                |
   |                    |                |
  base              end = rgn->base    rend

An additional check is needed to see if the end of the requested
region is greater than the memblock region:

   ----------------------
   |                     |
   |                     |
  rgn->base    base     rend      end
                |                  |
                |                  |
                --------------------

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
 mm/memblock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 5338237..e174ee0 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -459,7 +459,7 @@ static long __init_memblock __memblock_remove(struct memblock_type *type,
 		}
 
 		/* And check if we need to trim the top of a block */
-		if (base < rend)
+		if (base < rend && end > rend)
 			rgn->size -= rend - base;
 
 	}
-- 
1.7.8.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-29  4:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-29  2:25 [PATCH] mm/memblock.c: Correctly check whether to trim a block Laura Abbott
2012-03-29  4:01 ` Benjamin Herrenschmidt

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).