Skip to content

Commit

Permalink
ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects
Browse files Browse the repository at this point in the history
[ Upstream commit 883cf0d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
superm1 authored and gregkh committed Sep 23, 2023
1 parent 4180b3a commit 9e8bbde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/acpi/x86/s2idle.c
Expand Up @@ -113,6 +113,12 @@ static void lpi_device_get_constraints_amd(void)
union acpi_object *package = &out_obj->package.elements[i];

if (package->type == ACPI_TYPE_PACKAGE) {
if (lpi_constraints_table) {
acpi_handle_err(lps0_device_handle,
"Duplicate constraints list\n");
goto free_acpi_buffer;
}

lpi_constraints_table = kcalloc(package->package.count,
sizeof(*lpi_constraints_table),
GFP_KERNEL);
Expand Down

0 comments on commit 9e8bbde

Please sign in to comment.