Skip to content

Commit dbc3171

Browse files
samasth-norwaybjorn-helgaas
authored andcommitted
x86/PCI: Check pcie_find_root_port() return for NULL
If pcie_find_root_port() is unable to locate a Root Port, it will return NULL. Check the pointer for NULL before dereferencing it. This particular case is in a quirk for devices that are always below a Root Port, so this won't avoid a problem and doesn't need to be backported, but check as a matter of style and to prevent copy/paste mistakes. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Samasth Norway Ananda <[email protected]> [bhelgaas: drop Fixes: and explain why there's no problem in this case] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Mario Limonciello <[email protected]>
1 parent 8400291 commit dbc3171

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/pci/fixup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ static void amd_rp_pme_suspend(struct pci_dev *dev)
980980
return;
981981

982982
rp = pcie_find_root_port(dev);
983-
if (!rp->pm_cap)
983+
if (!rp || !rp->pm_cap)
984984
return;
985985

986986
rp->pme_support &= ~((PCI_PM_CAP_PME_D3hot|PCI_PM_CAP_PME_D3cold) >>
@@ -994,7 +994,7 @@ static void amd_rp_pme_resume(struct pci_dev *dev)
994994
u16 pmc;
995995

996996
rp = pcie_find_root_port(dev);
997-
if (!rp->pm_cap)
997+
if (!rp || !rp->pm_cap)
998998
return;
999999

10001000
pci_read_config_word(rp, rp->pm_cap + PCI_PM_PMC, &pmc);

0 commit comments

Comments
 (0)