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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Jul 2023 17:27:37 +0000 (18:27 +0100)
commit788c76c33df9758778b7fa7f25309a91276c9be1
treedbc202fcbc9e77483debaea04d88686226949974
parenta905b0b318ad7d37c3041573454129923e0a0723
PCI/ACPI: Validate acpi_pci_set_power_state() parameter

commit 5557b62634abbd55bab7b154ce4bca348ad7f96f upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/pci-acpi.c