[svn-commits] sruffell: linux/trunk r9503 - /linux/trunk/drivers/dahdi/voicebus/voicebus.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Dec 2 16:43:02 CST 2010
Author: sruffell
Date: Thu Dec 2 16:42:56 2010
New Revision: 9503
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9503
Log:
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 at digium.com>
Modified:
linux/trunk/drivers/dahdi/voicebus/voicebus.c
Modified: linux/trunk/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=9503&r1=9502&r2=9503
==============================================================================
--- linux/trunk/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/trunk/drivers/dahdi/voicebus/voicebus.c Thu Dec 2 16:42:56 2010
@@ -1174,7 +1174,7 @@
}
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 @@
enum voicebus_mode mode)
{
int retval = 0;
+ int reserved_iomem = 0;
BUG_ON(NULL == vb);
BUG_ON(NULL == board_name);
@@ -1770,12 +1771,17 @@
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 @@
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;
}
@@ -1854,6 +1858,11 @@
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;
More information about the svn-commits
mailing list