Re: [PATCH] PCI: Fix racing for pci device removing via sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
> 
> 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.

+	get_device(&pdev->bus->dev);

So the pci_bus' ref management is still needed.
 
 	err = device_schedule_callback(dev, remove_callback);
-	if (err)
+	if (err) {
+		put_device(&pdev->bus->dev);
+		pci_dev_put(pdev);
 		return err;
+	}
 
 	return count;
 }

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




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux