patch-2.4.2 linux/drivers/net/hamradio/yam.c

Next file: linux/drivers/net/hp-plus.c
Previous file: linux/drivers/net/hamradio/scc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.1/linux/drivers/net/hamradio/yam.c linux/drivers/net/hamradio/yam.c
@@ -45,7 +45,7 @@
 #include <linux/net.h>
 #include <linux/in.h>
 #include <linux/if.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <asm/bitops.h>
 #include <asm/io.h>
@@ -878,7 +878,6 @@
 
 	printk(KERN_INFO "%s at iobase 0x%lx irq %u uart %s\n", dev->name, dev->base_addr, dev->irq,
 		   uart_str[u]);
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -905,7 +904,6 @@
 
 	printk(KERN_INFO "%s: close yam at iobase 0x%lx irq %u\n",
 		   yam_drvname, dev->base_addr, dev->irq);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
@@ -938,14 +936,17 @@
 	case SIOCYAMSMCS:
 		if (netif_running(dev))
 			return -EINVAL;		/* Cannot change this parameter when up */
-		ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL);
-		if(ym==NULL)
+		if ((ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL)) == NULL)
 			return -ENOBUFS;
 		ym->bitrate = 9600;
-		if (copy_from_user(ym, ifr->ifr_data, sizeof(struct yamdrv_ioctl_mcs)))
-			 return -EFAULT;
-		if (ym->bitrate > YAM_MAXBITRATE)
+		if (copy_from_user(ym, ifr->ifr_data, sizeof(struct yamdrv_ioctl_mcs))) {
+			kfree(ym);
+			return -EFAULT;
+		}
+		if (ym->bitrate > YAM_MAXBITRATE) {
+			kfree(ym);
 			return -EINVAL;
+		}
 		add_mcs(ym->bits, ym->bitrate);
 		kfree(ym);
 		break;
@@ -1129,8 +1130,11 @@
 
 		if (register_netdev(dev)) {
 			printk(KERN_WARNING "yam: cannot register net device %s\n", dev->name);
+			dev->priv = NULL;
 			return -ENXIO;
 		}
+
+		SET_MODULE_OWNER(dev);
 	}
 
 	yam_timer.function = yam_dotimer;

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