[PATCH][ATM] iphase stack usage cleanup

chas williams (chas@locutus.cmf.nrl.navy.mil)
Mon, 5 May 2003 09:52:24 -0400


someone noted the iphase driver's stack usage. this
should take care of the biggest offender.

--- linux-2.5.68/drivers/atm/iphase.c.000 Mon May 5 08:43:18 2003
+++ linux-2.5.68/drivers/atm/iphase.c Mon May 5 09:41:56 2003
@@ -2789,11 +2789,15 @@
break;
case MEMDUMP_FFL:
{
- ia_regs_t regs_local;
- ffredn_t *ffL = &regs_local.ffredn;
- rfredn_t *rfL = &regs_local.rfredn;
+ ia_regs_t *regs_local;
+ ffredn_t *ffL;
+ rfredn_t *rfL;

if (!capable(CAP_NET_ADMIN)) return -EPERM;
+ regs_local = kmalloc(sizeof(*regs_local), GFP_KERNEL);
+ if (!regs_local) return -ENOMEM;
+ ffL = &regs_local->ffredn;
+ rfL = &regs_local->rfredn;
/* Copy real rfred registers into the local copy */
for (i=0; i<(sizeof (rfredn_t))/4; i++)
((u_int *)rfL)[i] = ((u_int *)iadev->reass_reg)[i] & 0xffff;
@@ -2801,8 +2805,11 @@
for (i=0; i<(sizeof (ffredn_t))/4; i++)
((u_int *)ffL)[i] = ((u_int *)iadev->seg_reg)[i] & 0xffff;

- if (copy_to_user(ia_cmds.buf, &regs_local,sizeof(ia_regs_t)))
+ if (copy_to_user(ia_cmds.buf, regs_local,sizeof(ia_regs_t))) {
+ kfree(regs_local);
return -EFAULT;
+ }
+ kfree(regs_local);
printk("Board %d registers dumped\n", board);
ia_cmds.status = 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/