diff options
author | Shaun Ruffell <sruffell@digium.com> | 2011-01-21 05:30:55 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2011-01-21 05:30:55 +0000 |
commit | 1715ce843c504f93710866f3275f7eeee83f8507 (patch) | |
tree | 8b84e965ffe59d74fe0d3ae76b148da6c059cd94 | |
parent | 7201e8858ba81d45e2a8f347341f3a224de30939 (diff) |
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>
Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=9503
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.4@9678 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | drivers/dahdi/voicebus/voicebus.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/dahdi/voicebus/voicebus.c b/drivers/dahdi/voicebus/voicebus.c index 702f565..d996356 100644 --- a/drivers/dahdi/voicebus/voicebus.c +++ b/drivers/dahdi/voicebus/voicebus.c @@ -1182,7 +1182,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); @@ -1717,6 +1717,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); @@ -1776,12 +1777,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->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE, @@ -1791,8 +1797,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; } @@ -1852,6 +1856,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; |