Re: [PATCH] PCI/PM: Reject invalid PMCSR when checking PME status
From: Lukas Wunner
Date: Tue Dec 01 2026 - 05:20:12 EST
On Tue, Dec 01, 2026 at 03:25:01PM +0800, xianhutan@xxxxxxxxxxxx wrote:
> +++ b/drivers/pci/pci.c
> @@ -2323,6 +2323,7 @@ void pcie_clear_root_pme_status(struct pci_dev *dev)
> bool pci_check_pme_status(struct pci_dev *dev)
> {
> int pmcsr_pos;
> + int rc;
> u16 pmcsr;
> bool ret = false;
>
> @@ -2330,7 +2331,10 @@ bool pci_check_pme_status(struct pci_dev *dev)
> return false;
>
> pmcsr_pos = dev->pm_cap + PCI_PM_CTRL;
> - pci_read_config_word(dev, pmcsr_pos, &pmcsr);
> + rc = pci_read_config_word(dev, pmcsr_pos, &pmcsr);
> + if (rc != PCIBIOS_SUCCESSFUL || pmcsr == 0xffff)
> + return false;
> +
You can just use PCI_POSSIBLE_ERROR() instead of checking for 0xffff.
I'm not sure whether checking the return value is necessary or useful,
usually checking for PCI_POSSIBLE_ERROR() is sufficient.
Thanks,
Lukas