OSDN Git Service

MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem()
authorTiezhu Yang <yangtiezhu@loongson.cn>
Tue, 24 May 2022 02:27:49 +0000 (10:27 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Tue, 24 May 2022 11:04:53 +0000 (13:04 +0200)
In the current code, the users usually need to make sure the value
of mem parameter is correct, but it is better to do some check to
avoid potential boot hangs.

This commit checks whether mem parameter is empty, if yes, return
-EINVAL before call memblock_remove() and memblock_add().

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/kernel/setup.c

index ad3aea8..1c7f916 100644 (file)
@@ -344,6 +344,11 @@ static int __init early_parse_mem(char *p)
 {
        phys_addr_t start, size;
 
+       if (!p) {
+               pr_err("mem parameter is empty, do nothing\n");
+               return -EINVAL;
+       }
+
        /*
         * If a user specifies memory size, we
         * blow away any automatically generated