s390/mem_detect: fix detect_memory() error handling
authorVasily Gorbik <gor@linux.ibm.com>
Fri, 27 Jan 2023 13:03:07 +0000 (14:03 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 6 Feb 2023 10:13:53 +0000 (11:13 +0100)
Currently if for some reason sclp_early_read_info() fails,
sclp_early_get_memsize() will not set max_physmem_end and it
will stay uninitialized. Any garbage value other than 0 will lead
to detect_memory() taking wrong path or returning a garbage value
as max_physmem_end. To avoid that simply initialize max_physmem_end.

Fixes: 73045a08cf55 ("s390: unify identity mapping limits handling")
Reported-by: Alexander Gordeev <agordeev@linux.ibm.com>
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/boot/mem_detect.c

index 7fa1a32ea0f3f095612917617573e9bd3d8af4ed..0a5821ef4f1fd74390fbbebef5540d59c1f069a5 100644 (file)
@@ -165,7 +165,7 @@ static void search_mem_end(void)
 
 unsigned long detect_memory(void)
 {
-       unsigned long max_physmem_end;
+       unsigned long max_physmem_end = 0;
 
        sclp_early_get_memsize(&max_physmem_end);