patch-2.4.7 linux/net/core/dv.c

Next file: linux/net/core/skbuff.c
Previous file: linux/net/core/dev.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.6/linux/net/core/dv.c linux/net/core/dv.c
@@ -66,6 +66,7 @@
 		} else {
 			memset(dev->divert, 0, sizeof(struct divert_blk));
 		}
+		dev_hold(dev);
 	} else {
 		printk(KERN_DEBUG "divert: not allocating divert_blk for non-ethernet device %s\n",
 		       dev->name);
@@ -84,6 +85,7 @@
 	if (dev->divert) {
 		kfree(dev->divert);
 		dev->divert=NULL;
+		dev_put(dev);
 		printk(KERN_DEBUG "divert: freeing divert_blk for %s\n",
 		       dev->name);
 	} else {
@@ -151,7 +153,8 @@
 int check_args(struct divert_cf *div_cf, struct net_device **dev)
 {
 	char devname[32];
-		
+	int ret;
+
 	if (dev == NULL)
 		return -EFAULT;
 	
@@ -170,16 +173,21 @@
 	/* dev should NOT be null */
 	if (*dev == NULL)
 		return -EINVAL;
-	
+
+	ret = 0;
+
 	/* user issuing the ioctl must be a super one :) */
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
+	if (!capable(CAP_SYS_ADMIN)) {
+		ret = -EPERM;
+		goto out;
+	}
 
 	/* Device must have a divert_blk member NOT null */
 	if ((*dev)->divert == NULL)
-		return -EFAULT;
-
-	return 0;
+		ret = -EINVAL;
+out:
+	dev_put(*dev);
+	return ret;
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)