| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * esrt.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 239 | 240 | { |
|---|
| 240 | 241 | void *va; |
|---|
| 241 | 242 | struct efi_system_resource_table tmpesrt; |
|---|
| 242 | | - struct efi_system_resource_entry_v1 *v1_entries; |
|---|
| 243 | 243 | size_t size, max, entry_size, entries_size; |
|---|
| 244 | 244 | efi_memory_desc_t md; |
|---|
| 245 | 245 | int rc; |
|---|
| 246 | 246 | phys_addr_t end; |
|---|
| 247 | + |
|---|
| 248 | + if (!efi_enabled(EFI_MEMMAP)) |
|---|
| 249 | + return; |
|---|
| 247 | 250 | |
|---|
| 248 | 251 | pr_debug("esrt-init: loading.\n"); |
|---|
| 249 | 252 | if (!esrt_table_exists()) |
|---|
| .. | .. |
|---|
| 284 | 287 | memcpy(&tmpesrt, va, sizeof(tmpesrt)); |
|---|
| 285 | 288 | early_memunmap(va, size); |
|---|
| 286 | 289 | |
|---|
| 287 | | - if (tmpesrt.fw_resource_version == 1) { |
|---|
| 288 | | - entry_size = sizeof (*v1_entries); |
|---|
| 289 | | - } else { |
|---|
| 290 | + if (tmpesrt.fw_resource_version != 1) { |
|---|
| 290 | 291 | pr_err("Unsupported ESRT version %lld.\n", |
|---|
| 291 | 292 | tmpesrt.fw_resource_version); |
|---|
| 292 | 293 | return; |
|---|
| 293 | 294 | } |
|---|
| 294 | 295 | |
|---|
| 296 | + entry_size = sizeof(struct efi_system_resource_entry_v1); |
|---|
| 295 | 297 | if (tmpesrt.fw_resource_count > 0 && max - size < entry_size) { |
|---|
| 296 | 298 | pr_err("ESRT memory map entry can only hold the header. (max: %zu size: %zu)\n", |
|---|
| 297 | 299 | max - size, entry_size); |
|---|