Revert "PCI: Use to_pci_driver() instead of pci_dev->driver"
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 10 Nov 2021 18:03:34 +0000 (12:03 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 11 Nov 2021 19:36:22 +0000 (13:36 -0600)
commite0217c5ba10d7bf640f038b2feae58e630f2f958
treed7899667bdfeea595319549c90a184ecf5849490
parent68da4e0eaaab421f228eac57cbe7505b136464af
Revert "PCI: Use to_pci_driver() instead of pci_dev->driver"

This reverts commit 2a4d9408c9e8b6f6fc150c66f3fef755c9e20d4a.

Robert reported a NULL pointer dereference caused by the PCI core
(local_pci_probe()) calling the i2c_designware_pci driver's
.runtime_resume() method before the .probe() method.  i2c_dw_pci_resume()
depends on initialization done by i2c_dw_pci_probe().

Prior to 2a4d9408c9e8 ("PCI: Use to_pci_driver() instead of
pci_dev->driver"), pci_pm_runtime_resume() avoided calling the
.runtime_resume() method because pci_dev->driver had not been set yet.

2a4d9408c9e8 and b5f9c644eb1b ("PCI: Remove struct pci_dev->driver"),
removed pci_dev->driver, replacing it by device->driver, which *has* been
set by this time, so pci_pm_runtime_resume() called the .runtime_resume()
method when it previously had not.

Fixes: 2a4d9408c9e8 ("PCI: Use to_pci_driver() instead of pci_dev->driver")
Link: https://lore.kernel.org/linux-i2c/CAP145pgdrdiMAT7=-iB1DMgA7t_bMqTcJL4N0=6u8kNY3EU0dw@mail.gmail.com/
Reported-by: Robert Święcki <robert@swiecki.net>
Tested-by: Robert Święcki <robert@swiecki.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/iov.c
drivers/pci/pci-driver.c
drivers/pci/pci.c
drivers/pci/pcie/err.c