diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-11-23 02:43:23 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2015-11-26 13:15:49 -0500 |
commit | 81d945772afccc77660374aa6e512184b9107580 (patch) | |
tree | 40dbe8d48f3a650871db0753c075d2f206fa7d13 | |
parent | 1944bf8e78b7178f8ebfeefaced738ce1d111a4c (diff) |
arm64: efi: deal with NULL return value of early_memremap()
Add NULL return value checks to two invocations of early_memremap()
in the UEFI init code. For the UEFI configuration tables, we just
warn since we have a better chance of being able to report the issue
in a way that can actually be noticed by a human operator if we don't
abort right away. For the UEFI memory map, however, all we can do is
panic() since we cannot proceed without a description of memory.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/kernel/efi.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index fe7cd1afa109..96e4b1b7de46 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c | |||
@@ -127,7 +127,11 @@ static int __init uefi_init(void) | |||
127 | table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables; | 127 | table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables; |
128 | config_tables = early_memremap(efi_to_phys(efi.systab->tables), | 128 | config_tables = early_memremap(efi_to_phys(efi.systab->tables), |
129 | table_size); | 129 | table_size); |
130 | 130 | if (config_tables == NULL) { | |
131 | pr_warn("Unable to map EFI config table array.\n"); | ||
132 | retval = -ENOMEM; | ||
133 | goto out; | ||
134 | } | ||
131 | retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables, | 135 | retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables, |
132 | sizeof(efi_config_table_64_t), NULL); | 136 | sizeof(efi_config_table_64_t), NULL); |
133 | 137 | ||
@@ -209,6 +213,14 @@ void __init efi_init(void) | |||
209 | PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK))); | 213 | PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK))); |
210 | memmap.phys_map = params.mmap; | 214 | memmap.phys_map = params.mmap; |
211 | memmap.map = early_memremap(params.mmap, params.mmap_size); | 215 | memmap.map = early_memremap(params.mmap, params.mmap_size); |
216 | if (memmap.map == NULL) { | ||
217 | /* | ||
218 | * If we are booting via UEFI, the UEFI memory map is the only | ||
219 | * description of memory we have, so there is little point in | ||
220 | * proceeding if we cannot access it. | ||
221 | */ | ||
222 | panic("Unable to map EFI memory map.\n"); | ||
223 | } | ||
212 | memmap.map_end = memmap.map + params.mmap_size; | 224 | memmap.map_end = memmap.map + params.mmap_size; |
213 | memmap.desc_size = params.desc_size; | 225 | memmap.desc_size = params.desc_size; |
214 | memmap.desc_version = params.desc_ver; | 226 | memmap.desc_version = params.desc_ver; |