patch-2.4.0-test11 linux/drivers/net/rrunner.c
Next file: linux/drivers/net/seeq8005.c
Previous file: linux/drivers/net/pppoe.c
Back to the patch index
Back to the overall index
- Lines: 140
- Date:
Thu Nov 16 12:51:28 2000
- Orig file:
v2.4.0-test10/linux/drivers/net/rrunner.c
- Orig date:
Sun Oct 8 10:50:19 2000
diff -u --recursive --new-file v2.4.0-test10/linux/drivers/net/rrunner.c linux/drivers/net/rrunner.c
@@ -1548,74 +1548,76 @@
unsigned int i;
int error = -EOPNOTSUPP;
- rrpriv = (struct rr_private *)dev->priv;
-
- spin_lock(&rrpriv->lock);
+ rrpriv = dev->priv;
switch(cmd){
case SIOCRRGFW:
if (!capable(CAP_SYS_RAWIO)){
- error = -EPERM;
- goto out;
- }
-
- if (rrpriv->fw_running){
- printk("%s: Firmware already running\n", dev->name);
- error = -EPERM;
- goto out;
+ return -EPERM;
}
image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
if (!image){
printk(KERN_ERR "%s: Unable to allocate memory "
"for EEPROM image\n", dev->name);
- error = -ENOMEM;
- goto out;
+ return -ENOMEM;
+ }
+
+ spin_lock(&rrpriv->lock);
+
+ if (rrpriv->fw_running){
+ printk("%s: Firmware already running\n", dev->name);
+ error = -EPERM;
+ goto out_spin;
}
+
i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES);
if (i != EEPROM_BYTES){
- kfree(image);
- printk(KERN_ERR "%s: Error reading EEPROM\n",
- dev->name);
+ printk(KERN_ERR "%s: Error reading EEPROM\n", dev->name);
error = -EFAULT;
- goto out;
+ goto out_spin;
}
+ spin_unlock(&rrpriv->lock);
error = copy_to_user(rq->ifr_data, image, EEPROM_BYTES);
if (error)
error = -EFAULT;
kfree(image);
- break;
+ return error;
+
case SIOCRRPFW:
if (!capable(CAP_SYS_RAWIO)){
- error = -EPERM;
- goto out;
- }
-
- if (rrpriv->fw_running){
- printk("%s: Firmware already running\n", dev->name);
- error = -EPERM;
- goto out;
+ return -EPERM;
}
image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
if (!image){
printk(KERN_ERR "%s: Unable to allocate memory "
"for EEPROM image\n", dev->name);
- error = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
if (!oldimage){
+ kfree(image);
printk(KERN_ERR "%s: Unable to allocate memory "
"for old EEPROM image\n", dev->name);
- error = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
- if (error)
- error = -EFAULT;
+ if (error) {
+ kfree(image);
+ kfree(oldimage);
+ return -EFAULT;
+ }
+
+ spin_lock(&rrpriv->lock);
+ if (rrpriv->fw_running){
+ kfree(oldimage);
+ printk("%s: Firmware already running\n", dev->name);
+ error = -EPERM;
+ goto out_spin;
+ }
printk("%s: Updating EEPROM firmware\n", dev->name);
@@ -1629,6 +1631,7 @@
printk(KERN_ERR "%s: Error reading back EEPROM "
"image\n", dev->name);
+ spin_unlock(&rrpriv->lock);
error = memcmp(image, oldimage, EEPROM_BYTES);
if (error){
printk(KERN_ERR "%s: Error verifying EEPROM image\n",
@@ -1637,16 +1640,16 @@
}
kfree(image);
kfree(oldimage);
- break;
+ return error;
+
case SIOCRRID:
- error = put_user(0x52523032, (int *)(&rq->ifr_data[0]));
- if (error)
- error = -EFAULT;
- break;
+ return put_user(0x52523032, (int *)(&rq->ifr_data[0]));
default:
+ return error;
}
- out:
+ out_spin:
+ kfree(image);
spin_unlock(&rrpriv->lock);
return error;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)