[zaptel-commits] mattf: branch mattf/zaptel-1.4-stackcleanup r4091 - /team/mattf/zaptel-1.4-st...

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Wed Mar 26 14:12:18 CDT 2008


Author: mattf
Date: Wed Mar 26 14:12:17 2008
New Revision: 4091

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4091
Log:
Initial stack reduction.  Allocate parameters on heap instead of stack.  Should save at least 160 bytes of stack space

Modified:
    team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c

Modified: team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c?view=diff&rev=4091&r1=4090&r2=4091
==============================================================================
--- team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c (original)
+++ team/mattf/zaptel-1.4-stackcleanup/kernel/zaptel-base.c Wed Mar 26 14:12:17 2008
@@ -4505,7 +4505,7 @@
 static int ioctl_echocancel(struct zt_chan *chan, struct zt_echocanparams *ecp, void *data)
 {
 	struct echo_can_state *ec = NULL, *tec;
-	struct zt_echocanparam params[ZT_MAX_ECHOCANPARAMS];
+	struct zt_echocanparam *params;
 	int ret;
 	unsigned long flags;
 
@@ -4536,10 +4536,14 @@
 	    !chan->span->echocan_with_params)
 		return -EINVAL;
 	
+	params = kmalloc(sizeof(params[0]) * ZT_MAX_ECHOCANPARAMS, GFP_KERNEL);
+
 	/* enable mode, need the params */
 	
-	if (copy_from_user(params, (struct zt_echocanparam *) data, sizeof(params[0]) * ecp->param_count))
-		return -EFAULT;
+	if (copy_from_user(params, (struct zt_echocanparam *) data, sizeof(params[0]) * ecp->param_count)) {
+		ret = -EFAULT;
+		goto exit_with_free;
+	}
 	
 	spin_lock_irqsave(&chan->lock, flags);
 	tec = chan->ec;
@@ -4578,7 +4582,7 @@
 		}
 		
 		if ((ret = echo_can_create(ecp, params, &ec)))
-			return ret;
+			goto exit_with_free;
 		
 		spin_lock_irqsave(&chan->lock, flags);
 		chan->echocancel = ecp->tap_length;
@@ -4591,6 +4595,8 @@
 		spin_unlock_irqrestore(&chan->lock, flags);
 	}
 
+exit_with_free:
+	kfree(params);
 	return ret;
 }
 




More information about the zaptel-commits mailing list