Skip to contentSkip to conversation

efi: ssdt: Don't free memory if ACPI table was loaded successfully

PATCH New Ard Biesheuvel 1 participant 1 message Oct 14, 2022 EFI

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 efi: ssdt: Don't free memory if ACPI table was loaded successfully

Amadeusz reports KASAN use-after-free errors introduced by commit 3881ee0b1edc ("efi: avoid efivars layer when loading SSDTs from variables"). The problem appears to be that the memory that holds the new ACPI table is now freed unconditionally, instead of only when the ACPI core reported a failure to load the table.

So let's fix this, by omitting the kfree() on success.

Fixes 3881ee0b1edc ("efi: avoid efivars layer when loading SSDTs from variables")
---
 drivers/firmware/efi/efi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/firmware/efi/efi.c +2 -0
index 9624735f1575..3ecdc43a3f2b 100644
@@ -271,6 +271,8 @@ static __init int efivar_ssdt_load(void)
 			acpi_status ret = acpi_load_table(data, NULL);
 			if (ret)
 				pr_err("failed to load table: %u\n", ret);
+			else
+				continue;
 		} else {
 			pr_err("failed to get var data: 0x%lx\n", status);
 		}
Signature · 1 line
2.35.1