[PATCH] PCI: Prevent users from disabling devices in use

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

 



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.

Signed-off-by: Keith Busch <keith.busch@xxxxxxxxx>
---
 drivers/pci/pci-sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 366d93af051d..7ff3a3dce641 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -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))
-- 
2.13.6




[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