lkml.org 
[lkml]   [2008]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] pci: Fixing drivers/pci/search.c compilation warning.
On Mon, Oct 27, 2008 at 03:13:51PM +0800, Zhao, Yu wrote:
> Matthew Wilcox wrote:
> >On Mon, Oct 27, 2008 at 11:18:43AM +0800, Zhao, Yu wrote:
> >>Matthew Wilcox wrote:
> >>>Yes, that's why pci_find_device() is deprecated. But it doesn't also
> >>>need to be buggy ;-)
> >>How about pci_get_bus_and_slot()? People would meet the problem with it
> >>anyway.
> >
> >What problem with it? It's documented to return the device with an
> >increased refcount, and the implementation appears to do exactly that:
> >
>
> 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?

Erm, no, the 'dev' cannot be destroyed because the caller has a refcount
on it. The physical device backing it might have gone away. The dev
won't be destroyed until its reference count reaches zero, which could
be any time someone calls pci_dev_put() on it. In the scenario you're
postulating, it would happen in pci_get_dev_by_id():

if (from)
pci_dev_put(from);

which is the last time that 'from' is referred to in that callchain.

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."


\
 
 \ /
  Last update: 2008-10-27 08:25    [W:0.381 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site