aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2012-09-03 11:39:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-04 14:40:41 -0400
commit4a7a4f95a5e15648f24a971b36b82adc36d2cb6b (patch)
tree863360d51acb404366dbdee5da69e856d026a2ec
parent4375e61ed21d629fe922b3e5591ad6588f715137 (diff)
staging: comedi: das08: Fix PCI ref count
When attaching a PCI device manually via the comedi driver `attach` hook (`das08_attach()`) (called by the comedi core for the `COMEDI_DEVCONFIG` ioctl), its reference count is incremented in the `for_each_pci_dev` loop (in `das08_find_pci()`). It is decremented when the `detach` hook (`das08_detach()`) is called to detach the device. However, when the PCI device is attached automatically via the `attach_pci` hook (`das08_attach_pci()`, called at probe time via `comedi_pci_auto_config()`) it's reference count is not incremented so there will be an unmatched decrement when detaching the device. Increment the PCI device reference count in `das08_attach_pci()` to correct the mismatch. Once support for manual configuration has been removed from this driver, the calls to `pci_dev_get()` and `pci_dev_put()` can be removed. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/das08.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 874e02e47668..c5676e267518 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -922,6 +922,13 @@ das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
922 dev_err(dev->class_dev, "BUG! cannot determine board type!\n"); 922 dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
923 return -EINVAL; 923 return -EINVAL;
924 } 924 }
925 /*
926 * Need to 'get' the PCI device to match the 'put' in das08_detach().
927 * TODO: Remove the pci_dev_get() and matching pci_dev_put() once
928 * support for manual attachment of PCI devices via das08_attach()
929 * has been removed.
930 */
931 pci_dev_get(pdev);
925 return das08_pci_attach_common(dev, pdev); 932 return das08_pci_attach_common(dev, pdev);
926} 933}
927 934