Commit 1cfc90ec authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI: Grab reference count on pci_dev if the pci driver binds to the device.

And remember to decrement the count after remove() is called.
parent 16360235
...@@ -138,10 +138,11 @@ static int pci_device_probe(struct device * dev) ...@@ -138,10 +138,11 @@ static int pci_device_probe(struct device * dev)
drv = to_pci_driver(dev->driver); drv = to_pci_driver(dev->driver);
pci_dev = to_pci_dev(dev); pci_dev = to_pci_dev(dev);
if (get_device(dev)) { pci_get_dev(pci_dev);
error = __pci_device_probe(drv, pci_dev); error = __pci_device_probe(drv, pci_dev);
put_device(dev); if (error)
} pci_put_dev(pci_dev);
return error; return error;
} }
...@@ -155,6 +156,7 @@ static int pci_device_remove(struct device * dev) ...@@ -155,6 +156,7 @@ static int pci_device_remove(struct device * dev)
drv->remove(pci_dev); drv->remove(pci_dev);
pci_dev->driver = NULL; pci_dev->driver = NULL;
} }
pci_put_dev(pci_dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment