wctdm24xxp, wcte12xp: Close a few potential resource assignment leaks.
There were some routes through the failure paths in __voicebus_init() where a registered memory region was not subsequently released. This change closes those paths. The result would be on subsequent loads of the driver after hitting the failure condition you would see "IO Registers are in use by another module." in dmesg. request_mem_region/release_mem_region should most likely be converted to devm_request_region and devm_release_region introduced in 2.6.20 (commit 9ac7849e35f705830f7b016ff272b0ff1f7ff759) which was introduced for reasons just such as this. Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9503 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
102a2f0982
commit
2175ea1293
@ -1174,7 +1174,7 @@ voicebus_release(struct voicebus *vb)
|
||||
}
|
||||
|
||||
release_mem_region(pci_resource_start(vb->pdev, 1),
|
||||
pci_resource_len(vb->pdev, 1));
|
||||
pci_resource_len(vb->pdev, 1));
|
||||
|
||||
pci_iounmap(vb->pdev, vb->iobase);
|
||||
pci_clear_mwi(vb->pdev);
|
||||
@ -1713,6 +1713,7 @@ __voicebus_init(struct voicebus *vb, const char *board_name,
|
||||
enum voicebus_mode mode)
|
||||
{
|
||||
int retval = 0;
|
||||
int reserved_iomem = 0;
|
||||
|
||||
BUG_ON(NULL == vb);
|
||||
BUG_ON(NULL == board_name);
|
||||
@ -1770,12 +1771,17 @@ __voicebus_init(struct voicebus *vb, const char *board_name,
|
||||
goto cleanup;
|
||||
}
|
||||
vb->iobase = pci_iomap(vb->pdev, 1, 0);
|
||||
if (!request_mem_region(pci_resource_start(vb->pdev, 1),
|
||||
pci_resource_len(vb->pdev, 1), board_name)) {
|
||||
if (request_mem_region(pci_resource_start(vb->pdev, 1),
|
||||
pci_resource_len(vb->pdev, 1),
|
||||
board_name)) {
|
||||
reserved_iomem = 1;
|
||||
} else {
|
||||
dev_err(&vb->pdev->dev, "IO Registers are in use by another "
|
||||
"module.\n");
|
||||
retval = -EIO;
|
||||
goto cleanup;
|
||||
if (!(*vb->debug)) {
|
||||
retval = -EIO;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
vb->pool = dma_pool_create(board_name, &vb->pdev->dev,
|
||||
@ -1792,8 +1798,6 @@ __voicebus_init(struct voicebus *vb, const char *board_name,
|
||||
Configure the hardware interface.
|
||||
---------------------------------------------------------------- */
|
||||
if (pci_set_dma_mask(vb->pdev, DMA_BIT_MASK(32))) {
|
||||
release_mem_region(pci_resource_start(vb->pdev, 1),
|
||||
pci_resource_len(vb->pdev, 1));
|
||||
dev_warn(&vb->pdev->dev, "No suitable DMA available.\n");
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1855,6 +1859,11 @@ cleanup:
|
||||
if (vb->pdev)
|
||||
pci_disable_device(vb->pdev);
|
||||
|
||||
if (reserved_iomem) {
|
||||
release_mem_region(pci_resource_start(vb->pdev, 1),
|
||||
pci_resource_len(vb->pdev, 1));
|
||||
}
|
||||
|
||||
if (0 == retval)
|
||||
retval = -EIO;
|
||||
return retval;
|
||||
|
Loading…
Reference in New Issue
Block a user