Commit 2040b0d8 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Greg Kroah-Hartman

PCI: Prevent sysfs disable of device while driver is attached

[ Upstream commit 6f5cdfa8 ]

Manipulating the enable_cnt behind the back of the driver will wreak
complete havoc with the kernel state, so disallow it.
Signed-off-by: default avatarChristoph Hellwig <>
Signed-off-by: default avatarBjorn Helgaas <>
Reviewed-by: default avatarJohannes Thumshirn <>
Acked-by: default avatarKeith Busch <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent d93663a7
......@@ -305,13 +305,16 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (!val) {
if (pci_is_enabled(pdev))
result = -EIO;
} else
if (dev->driver)
result = -EBUSY;
else if (val)
result = pci_enable_device(pdev);
else if (pci_is_enabled(pdev))
result = -EIO;
return result < 0 ? result : count;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment