mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
PCI: Prevent sysfs disable of device while driver is attached
[ Upstream commit 6f5cdfa802733dcb561bf664cc89d203f2fd958f ] Manipulating the enable_cnt behind the back of the driver will wreak complete havoc with the kernel state, so disallow it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Acked-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d93663a787
commit
2040b0d8c9
@ -305,13 +305,16 @@ static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
|
|||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (!val) {
|
device_lock(dev);
|
||||||
if (pci_is_enabled(pdev))
|
if (dev->driver)
|
||||||
pci_disable_device(pdev);
|
result = -EBUSY;
|
||||||
else
|
else if (val)
|
||||||
result = -EIO;
|
|
||||||
} else
|
|
||||||
result = pci_enable_device(pdev);
|
result = pci_enable_device(pdev);
|
||||||
|
else if (pci_is_enabled(pdev))
|
||||||
|
pci_disable_device(pdev);
|
||||||
|
else
|
||||||
|
result = -EIO;
|
||||||
|
device_unlock(dev);
|
||||||
|
|
||||||
return result < 0 ? result : count;
|
return result < 0 ? result : count;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user