[svn-commits] qwell: branch 1.2 r2443 - /branches/1.2/zaptel-base.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Apr 25 08:35:35 MST 2007


Author: qwell
Date: Wed Apr 25 10:35:34 2007
New Revision: 2443

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2443
Log:
Don't try to reference a variable on a channel that may not exist.

Modified:
    branches/1.2/zaptel-base.c

Modified: branches/1.2/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel-base.c?view=diff&rev=2443&r1=2442&r2=2443
==============================================================================
--- branches/1.2/zaptel-base.c (original)
+++ branches/1.2/zaptel-base.c Wed Apr 25 10:35:34 2007
@@ -1047,7 +1047,8 @@
 		kfree(rxgain);
 	if (ec)
 		echo_can_free(ec);
-	kfree(readchunkpreec);
+	if (readchunkpreec)
+		kfree(readchunkpreec);
 
 #ifdef CONFIG_ZAPATA_PPP
 	if (ppp) {
@@ -3869,13 +3870,17 @@
 			chans[i]->_confn = zt_get_conf_alias(stack.conf.confno);
 		}
 
-		if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_RX_PREECHO ||
-		    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_TX_PREECHO ||
-		    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO)
-			chans[stack.conf.confno]->readchunkpreec = kmalloc(sizeof(*chans[stack.conf.confno]->readchunkpreec) * ZT_CHUNKSIZE, GFP_KERNEL);
-		else {
-			kfree(chans[stack.conf.confno]->readchunkpreec);
-			chans[stack.conf.confno]->readchunkpreec = NULL;
+		if (chans[stack.conf.confno]) {
+			if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_RX_PREECHO ||
+			    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR_TX_PREECHO ||
+			    (stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH_PREECHO)
+				chans[stack.conf.confno]->readchunkpreec = kmalloc(sizeof(*chans[stack.conf.confno]->readchunkpreec) * ZT_CHUNKSIZE, GFP_KERNEL);
+			else {
+				if (chans[stack.conf.confno]->readchunkpreec) {
+					kfree(chans[stack.conf.confno]->readchunkpreec);
+					chans[stack.conf.confno]->readchunkpreec = NULL;
+				}
+			}
 		}
 
 		spin_unlock_irqrestore(&chan->lock, flags);



More information about the svn-commits mailing list