lkml.org 
[lkml]   [2010]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 13/25] lmb: Add debug markers at the end of the array
Date
Since we allocate one more than needed, why not do a bit of sanity checking
here to ensure we don't walk past the end of the array ?

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
lib/lmb.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/lib/lmb.c b/lib/lmb.c
index 27dbb9c..6765a3a 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/bitops.h>
+#include <linux/poison.h>
#include <linux/lmb.h>

struct lmb lmb;
@@ -112,6 +113,10 @@ void __init lmb_init(void)
lmb.reserved.regions = lmb_reserved_init_regions;
lmb.reserved.max = INIT_LMB_REGIONS;

+ /* Write a marker in the unused last array entry */
+ lmb.memory.regions[INIT_LMB_REGIONS].base = (phys_addr_t)RED_INACTIVE;
+ lmb.reserved.regions[INIT_LMB_REGIONS].base = (phys_addr_t)RED_INACTIVE;
+
/* Create a dummy zero size LMB which will get coalesced away later.
* This simplifies the lmb_add() code below...
*/
@@ -131,6 +136,12 @@ void __init lmb_analyze(void)
{
int i;

+ /* Check marker in the unused last array entry */
+ WARN_ON(lmb_memory_init_regions[INIT_LMB_REGIONS].base
+ != (phys_addr_t)RED_INACTIVE);
+ WARN_ON(lmb_reserved_init_regions[INIT_LMB_REGIONS].base
+ != (phys_addr_t)RED_INACTIVE);
+
lmb.memory_size = 0;

for (i = 0; i < lmb.memory.cnt; i++)
--
1.6.3.3


\
 
 \ /
  Last update: 2010-05-10 12:01    [from the cache]
©2003-2011 Jasper Spaans