Skip to content

Commit 91e9134

Browse files
committed
Merge tag 'pci-v4.0-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI fixes from Bjorn Helgaas: "Here are a couple updates for v4.0. One fixes a config accessor problem on APM X-Gene that we introduced when switching to generic config accessors, and the other fixes an older read-past-end-of-buffer problem in sysfs. APM X-Gene host bridge driver - Add register offset to config space base address (Feng Kan) Miscellaneous - Don't read past the end of sysfs "driver_override" buffer (Sasha Levin)" * tag 'pci-v4.0-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: PCI: xgene: Add register offset to config space base address PCI: Don't read past the end of sysfs "driver_override" buffer
2 parents d3dd73f + 085a68d commit 91e9134

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/pci/host/pci-xgene.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
127127
return false;
128128
}
129129

130-
static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
130+
static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
131131
int offset)
132132
{
133133
struct xgene_pcie_port *port = bus->sysdata;
@@ -137,7 +137,7 @@ static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn,
137137
return NULL;
138138

139139
xgene_pcie_set_rtdid_reg(bus, devfn);
140-
return xgene_pcie_get_cfg_base(bus);
140+
return xgene_pcie_get_cfg_base(bus) + offset;
141141
}
142142

143143
static struct pci_ops xgene_pcie_ops = {

drivers/pci/pci-sysfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ static ssize_t driver_override_store(struct device *dev,
521521
struct pci_dev *pdev = to_pci_dev(dev);
522522
char *driver_override, *old = pdev->driver_override, *cp;
523523

524-
if (count > PATH_MAX)
524+
/* We need to keep extra room for a newline */
525+
if (count >= (PAGE_SIZE - 1))
525526
return -EINVAL;
526527

527528
driver_override = kstrndup(buf, count, GFP_KERNEL);
@@ -549,7 +550,7 @@ static ssize_t driver_override_show(struct device *dev,
549550
{
550551
struct pci_dev *pdev = to_pci_dev(dev);
551552

552-
return sprintf(buf, "%s\n", pdev->driver_override);
553+
return snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
553554
}
554555
static DEVICE_ATTR_RW(driver_override);
555556

0 commit comments

Comments
 (0)