Re: [PATCH] PCI: Fix racing for pci device removing via sysfs
From: Yinghai Lu
Date: Mon Apr 29 2013 - 11:19:17 EST
On Mon, Apr 29, 2013 at 3:04 AM, Gu Zheng <guz.fnst@xxxxxxxxxxxxxx> wrote:
> Hi Yinghai,
> On 04/27/2013 05:01 AM, Yinghai Lu wrote:
>> On Fri, Apr 26, 2013 at 1:53 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>>> You can't be serious. This is a disgusting mess. Checking a list
>>> pointer for LIST_POISON1? As far as I'm concerned, this is a waste of
>>> my time.
looks like xhci is using that LIST_POISON1 ...
>> Well, then need to hold the bus ref, and check bus->devices list instead.
> @@ -341,6 +352,7 @@ remove_store(struct device *dev, struct
> int err;
> unsigned long val;
> + struct pci_dev *pdev;
> if (strict_strtoul(buf, 0, &val) < 0)
> return -EINVAL;
> @@ -351,9 +363,14 @@ remove_store(struct device *dev, struct
> /* An attribute cannot be unregistered by one of its own methods,
> * so we have to use this roundabout approach.
> + pdev = pci_dev_get(to_pci_dev(dev));
> There is no need to increase pci_dev's ref here, because we'll increase it
> in sysfs_schedule_callback.
ok, i missed that. if we can use LIST_POISON, then could be more simple.
> + get_device(&pdev->bus->dev);
> So the pci_bus' ref management is still needed.
No, we don't need that as first pci_stop_and_remove_bus_device()
already drop that reference.
Description: Binary data