[rfc -tip 2/4] x86,e820: __e820_add_region -- guard against array overflowed

From: Cyrill Gorcunov
Date: Mon Aug 24 2009 - 13:56:01 EST


Better to be paranoid against unpredicted nr_map modifications.

Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
---
arch/x86/kernel/e820.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.git/arch/x86/kernel/e820.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/e820.c
+++ linux-2.6.git/arch/x86/kernel/e820.c
@@ -115,7 +115,7 @@ static void __init __e820_add_region(str
{
int x = e820x->nr_map;

- if (x == ARRAY_SIZE(e820x->map)) {
+ if (x >= ARRAY_SIZE(e820x->map)) {
printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
return;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/