[svn-commits] sruffell: linux/trunk r10162 - /linux/trunk/drivers/dahdi/wctdm24xxp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 30 11:38:09 CDT 2011


Author: sruffell
Date: Tue Aug 30 11:38:06 2011
New Revision: 10162

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10162
Log:
wctdm24xxp: Protect creation / destruction of VPM instance.

Closes a small window of opportunity where one CPU might free a VPM
instance that the interrupt handler may currently be using.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks at digium.com>

Modified:
    linux/trunk/drivers/dahdi/wctdm24xxp/base.c

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=10162&r1=10161&r2=10162
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Tue Aug 30 11:38:06 2011
@@ -4518,6 +4518,8 @@
 {
 	int res;
 	struct vpmadt032_options options;
+	struct vpmadt032 *vpm;
+	unsigned long flags;
 
 	options.debug = debug;
 	options.vpmnlptype = vpmnlptype;
@@ -4537,8 +4539,11 @@
 	if (!res)
 		res = vpmadt032_init(wc->vpmadt032);
 	if (res) {
-		vpmadt032_free(wc->vpmadt032);
+		vpm = wc->vpmadt032;
+		spin_lock_irqsave(&wc->reglock, flags);
 		wc->vpmadt032 = NULL;
+		spin_unlock_irqrestore(&wc->reglock, flags);
+		vpmadt032_free(vpm);
 		return res;
 	}
 
@@ -4546,8 +4551,11 @@
 	 * particular board. */
 	res = config_vpmadt032(wc->vpmadt032, wc);
 	if (res) {
-		vpmadt032_free(wc->vpmadt032);
+		vpm = wc->vpmadt032;
+		spin_lock_irqsave(&wc->reglock, flags);
 		wc->vpmadt032 = NULL;
+		spin_unlock_irqrestore(&wc->reglock, flags);
+		vpmadt032_free(vpm);
 		return res;
 	}
 
@@ -5866,8 +5874,10 @@
 	voicebus_stop(&wc->vb);
 
 	if (vpmadt032) {
+		spin_lock_irqsave(&wc->reglock, flags);
+		wc->vpmadt032 = NULL;
+		spin_unlock_irqrestore(&wc->reglock, flags);
 		vpmadt032_free(vpmadt032);
-		wc->vpmadt032 = NULL;
 	} else if (vpmoct) {
 		spin_lock_irqsave(&wc->reglock, flags);
 		wc->vpmoct = NULL;




More information about the svn-commits mailing list