提交 fb4d64e7 编写于 作者: F Frederik Deweerdt 提交者: Linus Torvalds

[PATCH] pci_iomap_regions() error handling fix

It appears that the pcim_iomap_regions() function doesn't get the error
handling right. It BUGs early at boot with a backtrace along the lines of:

ahci_init
pci_register_driver
driver_register
[...]
ahci_init_one
pcim_iomap_region
pcim_iounmap

The following patch allows me to boot. Only the if(mask..) continue;
part fixes the problem actually, the gotos where changed so that we
don't try to unmap something we couldn't map anyway.
Signed-off-by: NFrederik Deweerdt <frederik.deweerdt@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f5de6111
...@@ -274,21 +274,21 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name) ...@@ -274,21 +274,21 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
rc = pci_request_region(pdev, i, name); rc = pci_request_region(pdev, i, name);
if (rc) if (rc)
goto err_region; goto err_inval;
rc = -ENOMEM; rc = -ENOMEM;
if (!pcim_iomap(pdev, i, 0)) if (!pcim_iomap(pdev, i, 0))
goto err_iomap; goto err_region;
} }
return 0; return 0;
err_iomap:
pcim_iounmap(pdev, iomap[i]);
err_region: err_region:
pci_release_region(pdev, i); pci_release_region(pdev, i);
err_inval: err_inval:
while (--i >= 0) { while (--i >= 0) {
if (!(mask & (1 << i)))
continue;
pcim_iounmap(pdev, iomap[i]); pcim_iounmap(pdev, iomap[i]);
pci_release_region(pdev, i); pci_release_region(pdev, i);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册