mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 16:12:02 +00:00
i7core_edac: Avoid PCI refcount to reach zero on successive load/reload
That's a nasty bug that took me a lot of time to track, and whose solution took just one line to solve. The best fragrances and the worse poisons are shipped on the smalest bottles. The drivers/pci/quick.c implements the pci_get_device function. The normal behavior is that you call it, the function returns you a pdev pointer and increment pdev->kobj.kref.refcount of the pci device. However, if you want to keep searching an object, you need to pass the previous pdev function to the search. When you use a not null pointer to pdev "from" field, pci_get_device will decrement pdev->kobj.kref.refcount, assuming that the driver won't be using the previous pdev. The solution is simple: we just need to call pci_dev_get() manually, for the pdev's that the driver will actually use. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
79daef2099
commit
a3e1541637
@ -1395,6 +1395,13 @@ static int i7core_get_onedevice(struct pci_dev **prev,
|
||||
dev_descr->func,
|
||||
PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
|
||||
|
||||
/*
|
||||
* As stated on drivers/pci/search.c, the reference count for
|
||||
* @from is always decremented if it is not %NULL. So, as we need
|
||||
* to get all devices up to null, we need to do a get for the device
|
||||
*/
|
||||
pci_dev_get(pdev);
|
||||
|
||||
*prev = pdev;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user