Skip to content

Commit f06e0ad

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Use device_lock_assert() to verify device lock is held
Multiple function comments say the function should be called with device_lock held. Check that by calling device_lock_assert(). Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20260116125742.1890-3-ilpo.jarvinen@linux.intel.com
1 parent 183c291 commit f06e0ad

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/pci/pci.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4970,6 +4970,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
49704970
* races with ->remove() by the device lock, which must be held by
49714971
* the caller.
49724972
*/
4973+
device_lock_assert(&dev->dev);
49734974
if (err_handler && err_handler->reset_prepare)
49744975
err_handler->reset_prepare(dev);
49754976
else if (dev->driver)
@@ -5040,7 +5041,9 @@ const struct pci_reset_fn_method pci_reset_fn_methods[] = {
50405041
* device including MSI, bus mastering, BARs, decoding IO and memory spaces,
50415042
* etc.
50425043
*
5043-
* Returns 0 if the device function was successfully reset or negative if the
5044+
* Context: The caller must hold the device lock.
5045+
*
5046+
* Return: 0 if the device function was successfully reset or negative if the
50445047
* device doesn't support resetting a single function.
50455048
*/
50465049
int __pci_reset_function_locked(struct pci_dev *dev)
@@ -5049,6 +5052,7 @@ int __pci_reset_function_locked(struct pci_dev *dev)
50495052
const struct pci_reset_fn_method *method;
50505053

50515054
might_sleep();
5055+
device_lock_assert(&dev->dev);
50525056

50535057
/*
50545058
* A reset method returns -ENOTTY if it doesn't support this device and
@@ -5171,13 +5175,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function);
51715175
* over the reset. It also differs from pci_reset_function() in that it
51725176
* requires the PCI device lock to be held.
51735177
*
5174-
* Returns 0 if the device function was successfully reset or negative if the
5178+
* Context: The caller must hold the device lock.
5179+
*
5180+
* Return: 0 if the device function was successfully reset or negative if the
51755181
* device doesn't support resetting a single function.
51765182
*/
51775183
int pci_reset_function_locked(struct pci_dev *dev)
51785184
{
51795185
int rc;
51805186

5187+
device_lock_assert(&dev->dev);
5188+
51815189
if (!pci_reset_supported(dev))
51825190
return -ENOTTY;
51835191

0 commit comments

Comments
 (0)