[zaptel-commits] sruffell: branch 1.4 r3586 - in /branches: 1.2/wctdm24xxp/ 1.2/wcte12xp/ 1.4/...

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Wed Jan 2 09:20:56 CST 2008


Author: sruffell
Date: Wed Jan  2 09:20:56 2008
New Revision: 3586

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3586
Log:
Move the release of VPMADT032 resources to after the interrupt handler has been freed.  Closes a 
small window of opportunity for NULL pointer access at driver unload time.

Modified:
    branches/1.2/wctdm24xxp/base.c
    branches/1.2/wcte12xp/base.c
    branches/1.4/wctdm24xxp/base.c
    branches/1.4/wcte12xp/base.c

Modified: branches/1.2/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wctdm24xxp/base.c?view=diff&rev=3586&r1=3585&r2=3586
==============================================================================
--- branches/1.2/wctdm24xxp/base.c (original)
+++ branches/1.2/wctdm24xxp/base.c Wed Jan  2 09:20:56 2008
@@ -3595,7 +3595,21 @@
 			clear_bit(VPM150M_ACTIVE, &vpm150m->control);
 			flush_workqueue(vpm150m->wq);
 			destroy_workqueue(vpm150m->wq);
-
+		}
+#endif
+
+		/* Stop any DMA */
+		wctdm_stop_dma(wc);
+
+		/* In case hardware is still there */
+		wctdm_disable_interrupts(wc);
+		
+		/* Immediately free resources */
+		free_irq(pdev->irq, wc);
+		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+
+#ifdef VPM150M_SUPPORT
+		if (vpm150m) {
 			spin_lock_irqsave(&wc->reglock, flags);
 			wc->vpm150m = NULL;
 			vpm150m->wc = NULL;
@@ -3604,16 +3618,6 @@
 			kfree(wc->vpm150m);
 		}
 #endif
-		/* Stop any DMA */
-		wctdm_stop_dma(wc);
-
-		/* In case hardware is still there */
-		wctdm_disable_interrupts(wc);
-		
-		/* Immediately free resources */
-		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
-		free_irq(pdev->irq, wc);
-
 		/* Release span, possibly delayed */
 		if (!wc->usecount)
 			wctdm_release(wc);

Modified: branches/1.2/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wcte12xp/base.c?view=diff&rev=3586&r1=3585&r2=3586
==============================================================================
--- branches/1.2/wcte12xp/base.c (original)
+++ branches/1.2/wcte12xp/base.c Wed Jan  2 09:20:56 2008
@@ -1979,28 +1979,30 @@
 		clear_bit(VPM150M_ACTIVE, &vpm150m->control);
 		flush_workqueue(vpm150m->wq);
 		destroy_workqueue(vpm150m->wq);
-
-		kfree(wc->vpm150m);
-
+	}
+#endif
+	/* Stop any DMA */
+	t1_stop_dma(wc);
+	
+	/* In case hardware is still there */
+	t1_disable_interrupts(wc);
+	
+	if (debug && wc->isrreaderrors)
+		debug_printk(1, "isrreaderrors=%d\n", wc->isrreaderrors);
+
+	/* Immediately free resources */
+	free_irq(pdev->irq, wc);
+	pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+	
+#ifdef VPM_SUPPORT
+	if(vpm150m) {
 		spin_lock_irqsave(&wc->reglock, flags);
 		wc->vpm150m = NULL;
 		vpm150m->wc = NULL;
 		spin_unlock_irqrestore(&wc->reglock, flags);
+		kfree(wc->vpm150m);
 	}
 #endif
-
-	/* Stop any DMA */
-	t1_stop_dma(wc);
-	
-	/* In case hardware is still there */
-	t1_disable_interrupts(wc);
-	
-	if (debug && wc->isrreaderrors)
-		debug_printk(1, "isrreaderrors=%d\n", wc->isrreaderrors);
-
-	/* Immediately free resources */
-	pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
-	free_irq(pdev->irq, wc);
 	
 	/* Release span, possibly delayed */
 	if (!wc->usecount)

Modified: branches/1.4/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp/base.c?view=diff&rev=3586&r1=3585&r2=3586
==============================================================================
--- branches/1.4/wctdm24xxp/base.c (original)
+++ branches/1.4/wctdm24xxp/base.c Wed Jan  2 09:20:56 2008
@@ -4238,31 +4238,35 @@
 #endif
 
 	if (wc) {
+
 #ifdef VPM150M_SUPPORT
 		if (vpm150m) {
 			clear_bit(VPM150M_DTMFDETECT, &vpm150m->control);
 			clear_bit(VPM150M_ACTIVE, &vpm150m->control);
 			flush_workqueue(vpm150m->wq);
 			destroy_workqueue(vpm150m->wq);
-
+		}
+#endif
+
+		/* Stop any DMA */
+		wctdm_stop_dma(wc);
+
+		/* In case hardware is still there */
+		wctdm_disable_interrupts(wc);
+		
+		/* Immediately free resources */
+		free_irq(pdev->irq, wc);
+		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+
+#ifdef VPM150M_SUPPORT
+		if (vpm150m) {
 			spin_lock_irqsave(&wc->reglock, flags);
 			wc->vpm150m = NULL;
 			vpm150m->wc = NULL;
 			spin_unlock_irqrestore(&wc->reglock, flags);
-
 			kfree(wc->vpm150m);
 		}
 #endif
-		/* Stop any DMA */
-		wctdm_stop_dma(wc);
-
-		/* In case hardware is still there */
-		wctdm_disable_interrupts(wc);
-		
-		/* Immediately free resources */
-		pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
-		free_irq(pdev->irq, wc);
-
 		/* Release span, possibly delayed */
 		if (!wc->usecount)
 			wctdm_release(wc);

Modified: branches/1.4/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/base.c?view=diff&rev=3586&r1=3585&r2=3586
==============================================================================
--- branches/1.4/wcte12xp/base.c (original)
+++ branches/1.4/wcte12xp/base.c Wed Jan  2 09:20:56 2008
@@ -1973,7 +1973,6 @@
 #ifdef VPM_SUPPORT
 	struct vpm150m *vpm150m = wc->vpm150m;
 #endif
-
 	if (!wc)
 		return;
 
@@ -1983,29 +1982,30 @@
 		clear_bit(VPM150M_ACTIVE, &vpm150m->control);
 		flush_workqueue(vpm150m->wq);
 		destroy_workqueue(vpm150m->wq);
-
-		kfree(wc->vpm150m);
-
+	}
+#endif
+	/* Stop any DMA */
+	t1_stop_dma(wc);
+	
+	/* In case hardware is still there */
+	t1_disable_interrupts(wc);
+	
+	if (debug && wc->isrreaderrors)
+		debug_printk(1, "isrreaderrors=%d\n", wc->isrreaderrors);
+
+	/* Immediately free resources */
+	free_irq(pdev->irq, wc);
+	pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
+
+#ifdef VPM_SUPPORT
+	if(vpm150m) {
 		spin_lock_irqsave(&wc->reglock, flags);
 		wc->vpm150m = NULL;
 		vpm150m->wc = NULL;
 		spin_unlock_irqrestore(&wc->reglock, flags);
+		kfree(wc->vpm150m);
 	}
 #endif
-
-	/* Stop any DMA */
-	t1_stop_dma(wc);
-	
-	/* In case hardware is still there */
-	t1_disable_interrupts(wc);
-	
-	if (debug && wc->isrreaderrors)
-		debug_printk(1, "isrreaderrors=%d\n", wc->isrreaderrors);
-
-	/* Immediately free resources */
-	pci_free_consistent(pdev, PCI_WINDOW_SIZE, (void *)wc->writechunk, wc->writedma);
-	free_irq(pdev->irq, wc);
-	
 	/* Release span, possibly delayed */
 	if (!wc->usecount)
 		t1_release(wc);




More information about the zaptel-commits mailing list