Matthew Wilcox wrote:On Mon, Oct 27, 2008 at 03:13:51PM +0800, Zhao, Yu wrote:Matthew Wilcox wrote:Erm, no, the 'dev' cannot be destroyed because the caller has a refcountOn Mon, Oct 27, 2008 at 11:18:43AM +0800, Zhao, Yu wrote:The 'dev' returned by pci_get_device() may be destroyed by PCI hotplug. I suppose that passing this 'dev' to pci_get_device() in the next loop would crash the system, right?Matthew Wilcox wrote:What problem with it? It's documented to return the device with anYes, that's why pci_find_device() is deprecated. But it doesn't alsoHow about pci_get_bus_and_slot()? People would meet the problem with it anyway.
need to be buggy ;-)
increased refcount, and the implementation appears to do exactly that:
on it. The physical device backing it might have gone away. The dev
Why does the caller have a reference count? I don't see we increase the reference count after the 'dev' is returned by following in pci_get_dev_by_id():
dev = bus_find_device(&pci_bus_type, dev_start, (void *)id,
match_pci_dev_by_id);
And this 'dev' becomes the 'from' in the next loop, but it may be destroyed before the 'pci_dev_get(from)', isn't it?