[PATCH] x86: change size if e820_update/remove_range

From: Yinghai Lu
Date: Tue Jun 24 2008 - 17:59:11 EST



in case someone using crazy parameter while calling them.

Signed-off-by: Yinghai Lu <yhlu.kernel@xxxxxxxxx>

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 512f779..6445220 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -405,6 +405,9 @@ u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,

BUG_ON(old_type == new_type);

+ if (size > (ULLONG_MAX - start))
+ size = ULLONG_MAX - start;
+
for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
u64 final_start, final_end;
@@ -436,6 +439,9 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
int i;
u64 real_removed_size = 0;

+ if (size > (ULLONG_MAX - start))
+ size = ULLONG_MAX - start;
+
for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
u64 final_start, final_end;
--
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/