Commit 93b5533a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pci-v4.14-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI fixes from Bjorn Helgaas:

 - fix CONFIG_PCI=n build error (introduced in v4.14-rc1) (Geert
   Uytterhoeven)

 - fix a race in sysfs driver_override store/show (Nicolai Stange)

* tag 'pci-v4.14-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI: Fix race condition with driver_override
  PCI: Add dummy pci_acs_enabled() for CONFIG_PCI=n build
parents a3583202 9561475d
...@@ -686,7 +686,7 @@ static ssize_t driver_override_store(struct device *dev, ...@@ -686,7 +686,7 @@ static ssize_t driver_override_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
char *driver_override, *old = pdev->driver_override, *cp; char *driver_override, *old, *cp;
/* We need to keep extra room for a newline */ /* We need to keep extra room for a newline */
if (count >= (PAGE_SIZE - 1)) if (count >= (PAGE_SIZE - 1))
...@@ -700,12 +700,15 @@ static ssize_t driver_override_store(struct device *dev, ...@@ -700,12 +700,15 @@ static ssize_t driver_override_store(struct device *dev,
if (cp) if (cp)
*cp = '\0'; *cp = '\0';
device_lock(dev);
old = pdev->driver_override;
if (strlen(driver_override)) { if (strlen(driver_override)) {
pdev->driver_override = driver_override; pdev->driver_override = driver_override;
} else { } else {
kfree(driver_override); kfree(driver_override);
pdev->driver_override = NULL; pdev->driver_override = NULL;
} }
device_unlock(dev);
kfree(old); kfree(old);
...@@ -716,8 +719,12 @@ static ssize_t driver_override_show(struct device *dev, ...@@ -716,8 +719,12 @@ static ssize_t driver_override_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
ssize_t len;
return snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override); device_lock(dev);
len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
device_unlock(dev);
return len;
} }
static DEVICE_ATTR_RW(driver_override); static DEVICE_ATTR_RW(driver_override);
......
...@@ -1685,6 +1685,8 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; } ...@@ -1685,6 +1685,8 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }
#define dev_is_pci(d) (false) #define dev_is_pci(d) (false)
#define dev_is_pf(d) (false) #define dev_is_pf(d) (false)
static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
{ return false; }
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
/* Include architecture-dependent settings and functions */ /* Include architecture-dependent settings and functions */
......
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