Commit 64b133d2 authored by Javier Achirica's avatar Javier Achirica Committed by Jeff Garzik

[wireless airo] Simplify dynamic buffer code in Cisco extensions.

parent 4a383d75
...@@ -5902,13 +5902,9 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5902,13 +5902,9 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
unsigned short ridcode; unsigned short ridcode;
unsigned char *iobuf; 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)
{ {
...@@ -5921,17 +5917,13 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5921,17 +5917,13 @@ 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))
ret = -EPERM; return -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))
ret = -EPERM; return -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;
...@@ -5939,13 +5931,16 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5939,13 +5931,16 @@ 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))))
ret = -EFAULT; return -EFAULT;
goto rr_free; return 0;
default: default:
ret = -EINVAL; return -EINVAL;
goto rr_free; break;
} }
if ((iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL)) == NULL)
return -ENOMEM;
PC4500_readrid(ai,ridcode,iobuf,RIDS_SIZE); 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
...@@ -5953,11 +5948,12 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5953,11 +5948,12 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
*/ */
if (copy_to_user(comp->data, iobuf, if (copy_to_user(comp->data, iobuf,
min((int)comp->len, (int)RIDS_SIZE))) min((int)comp->len, (int)RIDS_SIZE))) {
ret = -EFAULT; kfree (iobuf);
rr_free: return -EFAULT;
kfree(iobuf); }
return ret; kfree (iobuf);
return 0;
} }
/* /*
...@@ -5970,7 +5966,6 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5970,7 +5966,6 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
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; 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))
...@@ -5979,10 +5974,6 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -5979,10 +5974,6 @@ 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;
...@@ -6004,8 +5995,8 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6004,8 +5995,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)
ret = -EIO; return -EIO;
goto wr_free; return 0;
/* /*
* Evidently this code in the airo driver does not get a symbol * Evidently this code in the airo driver does not get a symbol
...@@ -6013,13 +6004,16 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6013,13 +6004,16 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
*/ */
case AIROPMACOFF: case AIROPMACOFF:
disable_MAC(ai); disable_MAC(ai);
goto wr_free; return 0;
/* 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:
if ((iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL)) == NULL)
return -ENOMEM;
PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE); PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE);
enabled = ai->micstats.enabled; enabled = ai->micstats.enabled;
...@@ -6027,23 +6021,25 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6027,23 +6021,25 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
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)RIDS_SIZE))) min((int)comp->len, (int)RIDS_SIZE))) {
ret = -EFAULT; kfree (iobuf);
goto wr_free; return -EFAULT;
}
kfree (iobuf);
return 0;
default: default:
ret = -EOPNOTSUPP; /* Blarg! */ return -EOPNOTSUPP; /* Blarg! */
goto wr_free;
} }
if(comp->len > RIDS_SIZE)
return -EINVAL;
if (comp->len > RIDS_SIZE) { if ((iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL)) == NULL)
ret = -EINVAL; return -ENOMEM;
goto wr_free;
}
if (copy_from_user(iobuf,comp->data,comp->len)) { if (copy_from_user(iobuf,comp->data,comp->len)) {
ret = -EFAULT; kfree (iobuf);
goto wr_free; return -EFAULT;
} }
if (comp->command == AIROPCFG) { if (comp->command == AIROPCFG) {
...@@ -6058,11 +6054,12 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { ...@@ -6058,11 +6054,12 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
ai->flags &= ~FLAG_ADHOC; ai->flags &= ~FLAG_ADHOC;
} }
if((*writer)(ai, ridcode, iobuf,comp->len)) if((*writer)(ai, ridcode, iobuf,comp->len)) {
ret = -EIO; kfree (iobuf);
wr_free: return -EIO;
kfree(iobuf); }
return ret; kfree (iobuf);
return 0;
} }
/***************************************************************************** /*****************************************************************************
......
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