diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 5ec0b24..2aba909 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1175,6 +1175,16 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj, if (port + count - 1 > pci_resource_end(pdev, bar)) return -EINVAL; + /* + * Architectures that have no separate I/O address space emulate port + * I/O with an MMIO window at PCI_IOBASE, so @port becomes an address + * in a Device memory mapping. Unaligned accesses to Device memory + * fault there, and @port is fully controlled by the file offset, so + * require the access to be naturally aligned. + */ + if (!IS_ALIGNED(port, count)) + return -EINVAL; + switch (count) { case 1: if (write)