]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects
authorMario Limonciello <mario.limonciello@amd.com>
Fri, 18 Aug 2023 19:40:03 +0000 (14:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:11:00 +0000 (11:11 +0200)
[ Upstream commit 883cf0d4cf288313b71146ddebdf5d647b76c78b ]

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>
drivers/acpi/x86/s2idle.c

index ec84da6cc1bffb6c2b370aad23fcd3c04afb28f5..5510657d4be81018addb5d8ab2343d80471030e3 100644 (file)
@@ -112,6 +112,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);