PCI/ACPI: Validate acpi_pci_set_power_state() parameter
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 21 Jun 2023 21:36:12 +0000 (16:36 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 23 Jun 2023 17:28:01 +0000 (12:28 -0500)
commit5557b62634abbd55bab7b154ce4bca348ad7f96f
tree238b913ad2be04a824d3cf9ce19541d74c90f30f
parent9e30fd26f43b89cb6b4e850a86caa2e50dedb454
PCI/ACPI: Validate acpi_pci_set_power_state() parameter

Previously acpi_pci_set_power_state() assumed the requested power state was
valid (PCI_D0 ... PCI_D3cold).  If a caller supplied something else, we
could index outside the state_conv[] array and pass junk to
acpi_device_set_power().

Validate the pci_power_t parameter and return -EINVAL if it's invalid.

Link: https://lore.kernel.org/r/20230621222857.GA122930@bhelgaas
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
drivers/pci/pci-acpi.c