From: "Zhao, Yu" <yu.zhao@intel.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Yu Zhao <yu.zhao@uniscape.net>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"greg@kroah.com" <greg@kroah.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@kernel.org" <stable@kernel.org>,
Rakib Mullick <rakib.mullick@gmail.com>
Subject: Re: [PATCH] pci: Fixing drivers/pci/search.c compilation warning.
Date: Mon, 27 Oct 2008 15:34:14 +0800 [thread overview]
Message-ID: <49056EF6.3000904@intel.com> (raw)
In-Reply-To: <20081027072137.GZ26094@parisc-linux.org>
Matthew Wilcox wrote:
> 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
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?
> 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.
>
next prev parent reply other threads:[~2008-10-27 7:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b9df5fa10809280816u23ef3021k7eee287a237b72ae@mail.gmail.com>
2008-09-28 16:32 ` [PATCH] pci: Fixing drivers/pci/search.c compilation warning Matthew Wilcox
2008-10-21 1:13 ` Matthew Wilcox
2008-10-21 1:29 ` Jesse Barnes
2008-10-21 17:24 ` Jesse Barnes
2008-10-26 12:51 ` Yu Zhao
2008-10-26 18:34 ` Matthew Wilcox
2008-10-27 3:18 ` Zhao, Yu
2008-10-27 7:07 ` Matthew Wilcox
2008-10-27 7:13 ` Zhao, Yu
2008-10-27 7:21 ` Matthew Wilcox
2008-10-27 7:34 ` Zhao, Yu [this message]
2008-10-27 7:43 ` Zhao, Yu
2008-10-27 7:45 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49056EF6.3000904@intel.com \
--to=yu.zhao@intel.com \
--cc=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=rakib.mullick@gmail.com \
--cc=stable@kernel.org \
--cc=yu.zhao@uniscape.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox