Skip to contentSkip to conversation

PCI: Prevent users from disabling devices in use

PATCH New Keith Busch 1 participant 1 message May 18, 2018 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Prevent users from disabling devices in use

This patch returns busy status if a user tried to alter the enabled status of a device owned by a driver. There is no good reason to provide a convenient method to a user for altering the fundamental state of a pci device out from under a driver using it.

---
 drivers/pci/pci-sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/pci-sysfs.c +2 -0
index 366d93af051d..7ff3a3dce641 100644
@@ -287,6 +287,8 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
 	/* this can crash the machine when done on the "wrong" device */
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
+	if (pdev->driver)
+		return -EBUSY;
 
 	if (!val) {
 		if (pci_is_enabled(pdev))
Signature · 1 line
2.13.6