Unverified Commit 962fce19 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4105 PCI/sysfs: Take reference on device to be removed

parents 1cb962a5 f3ffd503
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -483,12 +483,17 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{
	unsigned long val;
	struct pci_dev *pdev = to_pci_dev(dev);

	if (kstrtoul(buf, 0, &val) < 0)
		return -EINVAL;

	if (val && device_remove_file_self(dev, attr))
		pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
	if (val) {
		pci_dev_get(pdev);
		if (device_remove_file_self(dev, attr))
			pci_stop_and_remove_bus_device_locked(pdev);
		pci_dev_put(pdev);
	}
	return count;
}
static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,