x86: Fix panic when handling "mem={invalid}" param
authorKamal Mostafa <kamal@canonical.com>
Fri, 4 Feb 2011 01:38:04 +0000 (17:38 -0800)
committerIngo Molnar <mingo@elte.hu>
Mon, 14 Feb 2011 12:15:43 +0000 (13:15 +0100)
Avoid removing all of memory and panicing when "mem={invalid}"
is specified, e.g. mem=blahblah, mem=0, or mem=nopentium (on
platforms other than x86_32).

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
BugLink: http://bugs.launchpad.net/bugs/553464
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: <stable@kernel.org> # .3x: as far back as it applies
LKML-Reference: <1296783486-23033-1-git-send-email-kamal@canonical.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/e820.c

index 294f26da0c0ce448f294ceacd162da3ff77b1f5f..55a59d889dbd4e99f5a9a40245e03521d591df19 100644 (file)
@@ -856,6 +856,9 @@ static int __init parse_memopt(char *p)
 
        userdef = 1;
        mem_size = memparse(p, &p);
+       /* don't remove all of memory when handling "mem={invalid}" param */
+       if (mem_size == 0)
+               return -EINVAL;
        e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
 
        return 0;