Commit d84366b4 authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman

[PATCH] reduce stack in wireless/airo.c

This reduces stack usage in drivers/net/wireless/airo.c by
dynamically allocating 2KB buffers in 2 places.
parent 45a522ed
...@@ -5894,6 +5894,7 @@ struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) ...@@ -5894,6 +5894,7 @@ struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
#endif /* WIRELESS_EXT */ #endif /* WIRELESS_EXT */
#ifdef CISCO_EXT #ifdef CISCO_EXT
#define RIDS_SIZE 2048
/* /*
* This just translates from driver IOCTL codes to the command codes to * This just translates from driver IOCTL codes to the command codes to
* feed to the radio's host interface. Things can be added/deleted * feed to the radio's host interface. Things can be added/deleted
...@@ -5902,11 +5903,15 @@ struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) ...@@ -5902,11 +5903,15 @@ struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
*/ */
static int readrids(struct net_device *dev, aironet_ioctl *comp) { static int readrids(struct net_device *dev, aironet_ioctl *comp) {
unsigned short ridcode; unsigned short ridcode;
unsigned char iobuf[2048]; unsigned char *iobuf;
struct airo_info *ai = dev->priv; struct airo_info *ai = dev->priv;
int ret = 0;
if (ai->flags & FLAG_FLASHING) if (ai->flags & FLAG_FLASHING)
return -EIO; return -EIO;
iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL);
if (!iobuf)
return -ENOMEM;
switch(comp->command) switch(comp->command)
{ {
...@@ -5919,13 +5924,17 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5919,13 +5924,17 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
case AIROGEHTENC: ridcode = RID_ETHERENCAP; break; case AIROGEHTENC: ridcode = RID_ETHERENCAP; break;
case AIROGWEPKTMP: ridcode = RID_WEP_TEMP; case AIROGWEPKTMP: ridcode = RID_WEP_TEMP;
/* Only super-user can read WEP keys */ /* Only super-user can read WEP keys */
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN)) {
return -EPERM; ret = -EPERM;
goto rr_free;
}
break; break;
case AIROGWEPKNV: ridcode = RID_WEP_PERM; case AIROGWEPKNV: ridcode = RID_WEP_PERM;
/* Only super-user can read WEP keys */ /* Only super-user can read WEP keys */
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN)) {
return -EPERM; ret = -EPERM;
goto rr_free;
}
break; break;
case AIROGSTAT: ridcode = RID_STATUS; break; case AIROGSTAT: ridcode = RID_STATUS; break;
case AIROGSTATSD32: ridcode = RID_STATSDELTA; break; case AIROGSTATSD32: ridcode = RID_STATSDELTA; break;
...@@ -5933,23 +5942,25 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5933,23 +5942,25 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
case AIROGMICSTATS: case AIROGMICSTATS:
if (copy_to_user(comp->data, &ai->micstats, if (copy_to_user(comp->data, &ai->micstats,
min((int)comp->len,(int)sizeof(ai->micstats)))) min((int)comp->len,(int)sizeof(ai->micstats))))
return -EFAULT; ret = -EFAULT;
return 0; goto rr_free;
default: default:
return -EINVAL; ret = -EINVAL;
break; goto rr_free;
} }
PC4500_readrid(ai,ridcode,iobuf,sizeof(iobuf)); PC4500_readrid(ai,ridcode,iobuf,RIDS_SIZE);
/* get the count of bytes in the rid docs say 1st 2 bytes is it. /* get the count of bytes in the rid docs say 1st 2 bytes is it.
* then return it to the user * then return it to the user
* 9/22/2000 Honor user given length * 9/22/2000 Honor user given length
*/ */
if (copy_to_user(comp->data, iobuf, if (copy_to_user(comp->data, iobuf,
min((int)comp->len, (int)sizeof(iobuf)))) min((int)comp->len, (int)RIDS_SIZE)))
return -EFAULT; ret = -EFAULT;
return 0; rr_free:
kfree(iobuf);
return ret;
} }
/* /*
...@@ -5961,7 +5972,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5961,7 +5972,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
int ridcode, enabled; int ridcode, enabled;
Resp rsp; Resp rsp;
static int (* writer)(struct airo_info *, u16 rid, const void *, int); static int (* writer)(struct airo_info *, u16 rid, const void *, int);
unsigned char iobuf[2048]; unsigned char *iobuf;
int ret = 0;
/* Only super-user can write RIDs */ /* Only super-user can write RIDs */
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
...@@ -5970,6 +5982,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5970,6 +5982,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
if (ai->flags & FLAG_FLASHING) if (ai->flags & FLAG_FLASHING)
return -EIO; return -EIO;
iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL);
if (!iobuf)
return -ENOMEM;
ridcode = 0; ridcode = 0;
writer = do_writerid; writer = do_writerid;
...@@ -5991,8 +6007,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5991,8 +6007,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
*/ */
case AIROPMACON: case AIROPMACON:
if (enable_MAC(ai, &rsp) != 0) if (enable_MAC(ai, &rsp) != 0)
return -EIO; ret = -EIO;
return 0; goto wr_free;
/* /*
* Evidently this code in the airo driver does not get a symbol * Evidently this code in the airo driver does not get a symbol
...@@ -6000,32 +6016,38 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6000,32 +6016,38 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
*/ */
case AIROPMACOFF: case AIROPMACOFF:
disable_MAC(ai); disable_MAC(ai);
return 0; goto wr_free;
/* This command merely clears the counts does not actually store any data /* This command merely clears the counts does not actually store any data
* only reads rid. But as it changes the cards state, I put it in the * only reads rid. But as it changes the cards state, I put it in the
* writerid routines. * writerid routines.
*/ */
case AIROPSTCLR: case AIROPSTCLR:
PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,sizeof(iobuf)); PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE);
enabled = ai->micstats.enabled; enabled = ai->micstats.enabled;
memset(&ai->micstats,0,sizeof(ai->micstats)); memset(&ai->micstats,0,sizeof(ai->micstats));
ai->micstats.enabled = enabled; ai->micstats.enabled = enabled;
if (copy_to_user(comp->data, iobuf, if (copy_to_user(comp->data, iobuf,
min((int)comp->len, (int)sizeof(iobuf)))) min((int)comp->len, (int)RIDS_SIZE)))
return -EFAULT; ret = -EFAULT;
return 0; goto wr_free;
default: default:
return -EOPNOTSUPP; /* Blarg! */ ret = -EOPNOTSUPP; /* Blarg! */
goto wr_free;
} }
if(comp->len > sizeof(iobuf))
return -EINVAL;
if (copy_from_user(iobuf,comp->data,comp->len)) if (comp->len > RIDS_SIZE) {
return -EFAULT; ret = -EINVAL;
goto wr_free;
}
if (copy_from_user(iobuf,comp->data,comp->len)) {
ret = -EFAULT;
goto wr_free;
}
if (comp->command == AIROPCFG) { if (comp->command == AIROPCFG) {
ConfigRid *cfg = (ConfigRid *)iobuf; ConfigRid *cfg = (ConfigRid *)iobuf;
...@@ -6040,8 +6062,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6040,8 +6062,10 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
} }
if((*writer)(ai, ridcode, iobuf,comp->len)) if((*writer)(ai, ridcode, iobuf,comp->len))
return -EIO; ret = -EIO;
return 0; wr_free:
kfree(iobuf);
return ret;
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment