mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
pcnet32: Use pci_resource_len to validate PCI resource
[ Upstream commit 66c3f05ddc ]
pci_resource_start() is not a good indicator to determine if a PCI
resource exists or not, since the resource may start at address 0.
This is seen when trying to instantiate the driver in qemu for riscv32
or riscv64.
pci 0000:00:01.0: reg 0x10: [io 0x0000-0x001f]
pci 0000:00:01.0: reg 0x14: [mem 0x00000000-0x0000001f]
...
pcnet32: card has no PCI IO resources, aborting
Use pci_resouce_len() instead.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
248b9b61b9
commit
2e08d9a568
|
|
@ -1534,8 +1534,7 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
}
|
}
|
||||||
pci_set_master(pdev);
|
pci_set_master(pdev);
|
||||||
|
|
||||||
ioaddr = pci_resource_start(pdev, 0);
|
if (!pci_resource_len(pdev, 0)) {
|
||||||
if (!ioaddr) {
|
|
||||||
if (pcnet32_debug & NETIF_MSG_PROBE)
|
if (pcnet32_debug & NETIF_MSG_PROBE)
|
||||||
pr_err("card has no PCI IO resources, aborting\n");
|
pr_err("card has no PCI IO resources, aborting\n");
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
|
|
@ -1548,6 +1547,8 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
pr_err("architecture does not support 32bit PCI busmaster DMA\n");
|
pr_err("architecture does not support 32bit PCI busmaster DMA\n");
|
||||||
goto err_disable_dev;
|
goto err_disable_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ioaddr = pci_resource_start(pdev, 0);
|
||||||
if (!request_region(ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_pci")) {
|
if (!request_region(ioaddr, PCNET32_TOTAL_SIZE, "pcnet32_probe_pci")) {
|
||||||
if (pcnet32_debug & NETIF_MSG_PROBE)
|
if (pcnet32_debug & NETIF_MSG_PROBE)
|
||||||
pr_err("io address range already allocated\n");
|
pr_err("io address range already allocated\n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user