Skip to content

Commit

Permalink
staging: comedi: amplc_pc236: Fix PCI ref count
Browse files Browse the repository at this point in the history
When attaching a PCI device manually via the comedi driver `attach` hook
(`pc236_attach()`) (called by the comedi core for the `COMEDI_DEVCONFIG`
ioctl), its reference count is incremented in the `for_each_pci_dev`
loop (in `pc236_find_pci_dev()`).  It is decremented when the `detach`
hook (`pc236_detach()`) is called to detach the device.  However, when
the PCI device is attached automatically via the `attach_pci` hook
(`pc236_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 `pc236_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>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Sep 4, 2012
1 parent 1a6671d commit 3abcfe0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/staging/comedi/drivers/amplc_pc236.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
return -EINVAL;
}
/*
* Need to 'get' the PCI device to match the 'put' in pc236_detach().
* TODO: Remove the pci_dev_get() and matching pci_dev_put() once
* support for manual attachment of PCI devices via pc236_attach()
* has been removed.
*/
pci_dev_get(pci_dev);
return pc236_pci_common_attach(dev, pci_dev);
}

Expand Down

0 comments on commit 3abcfe0

Please sign in to comment.