Skip to content

Commit 187fade

Browse files
vdsaogregkh
authored andcommitted
fpga: altera-cvp: fix 'bad IO access' on x86_64
If mapping the CvP BAR fails, we still can configure the FPGA via PCI config space access. In this case the iomap pointer is NULL. On x86_64, passing NULL address to pci_iounmap() generates "Bad IO access at port 0x0" output with stack call trace. Fix it. Signed-off-by: Anatolij Gustschin <agust@denx.de> Acked-by: Alan Tull <atull@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e51060 commit 187fade

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎drivers/fpga/altera-cvp.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ static int altera_cvp_probe(struct pci_dev *pdev,
477477
return 0;
478478

479479
err_unmap:
480-
pci_iounmap(pdev, conf->map);
480+
if (conf->map)
481+
pci_iounmap(pdev, conf->map);
481482
pci_release_region(pdev, CVP_BAR);
482483
err_disable:
483484
cmd &= ~PCI_COMMAND_MEMORY;
@@ -493,7 +494,8 @@ static void altera_cvp_remove(struct pci_dev *pdev)
493494

494495
driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg);
495496
fpga_mgr_unregister(mgr);
496-
pci_iounmap(pdev, conf->map);
497+
if (conf->map)
498+
pci_iounmap(pdev, conf->map);
497499
pci_release_region(pdev, CVP_BAR);
498500
pci_read_config_word(pdev, PCI_COMMAND, &cmd);
499501
cmd &= ~PCI_COMMAND_MEMORY;

0 commit comments

Comments
 (0)