Skip to content

Commit 883cf0d

Browse files
superm1rafaeljw
authored andcommitted
ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects
If a badly constructed firmware includes multiple `ACPI_TYPE_PACKAGE` objects while evaluating the AMD LPS0 _DSM, there will be a memory leak. Explicitly guard against this. Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3c6b121 commit 883cf0d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ static void lpi_device_get_constraints_amd(void)
113113
union acpi_object *package = &out_obj->package.elements[i];
114114

115115
if (package->type == ACPI_TYPE_PACKAGE) {
116+
if (lpi_constraints_table) {
117+
acpi_handle_err(lps0_device_handle,
118+
"Duplicate constraints list\n");
119+
goto free_acpi_buffer;
120+
}
121+
116122
lpi_constraints_table = kcalloc(package->package.count,
117123
sizeof(*lpi_constraints_table),
118124
GFP_KERNEL);

0 commit comments

Comments
 (0)