PCI: Protect pci_driver->sriov_configure() usage with device_lock()
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 22 May 2017 22:50:23 +0000 (15:50 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 14 Jun 2017 22:41:19 +0000 (17:41 -0500)
commit17530e71e0166a37f8e20a9b7bcf1d50ae3cff8e
tree985e0214ae3fae454db01acfdc1566d3c9d89798
parentd40b7fd2cbcbeeff36e52aef2aa44e03a2ab7345
PCI: Protect pci_driver->sriov_configure() usage with device_lock()

Every method in struct device_driver or structures derived from it like
struct pci_driver MUST provide exclusion vs the driver's ->remove() method,
usually by using device_lock().

Protect use of pci_driver->sriov_configure() by holding the device lock
while calling it.

The PCI core sets the pci_dev->driver pointer in local_pci_probe() before
calling ->probe() and only clears it after ->remove().  This means driver's
->sriov_configure() callback will happily race with probe() and remove(),
most likely leading to BUGs, since drivers don't expect this.

Remove the iov lock completely, since we remove the last user.

[bhelgaas: changelog, thanks to Christoph for locking rule]
Link: http://lkml.kernel.org/r/20170522225023.14010-1-jakub.kicinski@netronome.com
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
drivers/pci/iov.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.h