Re: [PATCH] call 'pci_dev_put' after pci_get_device

From: Brian Gerst
Date: Mon Oct 25 2004 - 08:49:26 EST


shaohua li wrote:
Hi,
Some code didn't call 'pci_dev_put' after pci_get_device. Below is an
incomplete list.

Thanks,
Shaohua

If pci_get_device() is passed in a non-NULL dev it internally does a pci_dev_put(). So if you do a complete while loop (ie. no breaks, gotos or returns), pci_dev_put() is unnecessary.


Signed-off-by: Li Shaohua <shaoh.li@xxxxxxxxx>

===== drivers/pci/pci.c 1.73 vs edited =====
--- 1.73/drivers/pci/pci.c 2004-10-07 00:42:55 +08:00
+++ edited/drivers/pci/pci.c 2004-10-25 17:30:36 +08:00
@@ -734,6 +734,7 @@ static int __devinit pci_init(void)
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pci_fixup_device(pci_fixup_final, dev);
+ pci_dev_put(dev);
}
return 0;
}
===== drivers/pci/quirks.c 1.55 vs edited =====
--- 1.55/drivers/pci/quirks.c 2004-10-20 00:54:38 +08:00
+++ edited/drivers/pci/quirks.c 2004-10-25 17:29:48 +08:00
@@ -38,6 +38,7 @@ static void __devinit quirk_passive_rele
dlc |= 1<<1;
pci_write_config_byte(d, 0x82, dlc);
}
+ pci_dev_put(d);
}
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, quirk_passive_release
);
===== drivers/pci/setup-irq.c 1.5 vs edited =====
--- 1.5/drivers/pci/setup-irq.c 2004-10-07 00:44:51 +08:00
+++ edited/drivers/pci/setup-irq.c 2004-10-25 17:29:08 +08:00
@@ -67,5 +67,6 @@ pci_fixup_irqs(u8 (*swizzle)(struct pci_
struct pci_dev *dev = NULL;
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pdev_fixup_irq(dev, swizzle, map_irq);
+ pci_dev_put(dev);
}
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/