Commit 1c00c05b authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[NET]: Fix missing netdev unregister/free in netrom and rose protocols.

Also, fix a object size vs. pointer size thinko.
parent 96828577
...@@ -1377,7 +1377,7 @@ static int __init nr_proto_init(void) ...@@ -1377,7 +1377,7 @@ static int __init nr_proto_init(void)
{ {
int i; int i;
if (nr_ndevs > 0x7fffffff/sizeof(struct net_device)) { if (nr_ndevs > 0x7fffffff/sizeof(struct net_device *)) {
printk(KERN_ERR "NET/ROM: nr_proto_init - nr_ndevs parameter to large\n"); printk(KERN_ERR "NET/ROM: nr_proto_init - nr_ndevs parameter to large\n");
return -1; return -1;
} }
...@@ -1405,6 +1405,7 @@ static int __init nr_proto_init(void) ...@@ -1405,6 +1405,7 @@ static int __init nr_proto_init(void)
dev->base_addr = i; dev->base_addr = i;
if (register_netdev(dev)) { if (register_netdev(dev)) {
printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n"); printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n");
free_netdev(dev);
goto fail; goto fail;
} }
dev_nr[i] = dev; dev_nr[i] = dev;
...@@ -1433,8 +1434,10 @@ static int __init nr_proto_init(void) ...@@ -1433,8 +1434,10 @@ static int __init nr_proto_init(void)
return 0; return 0;
fail: fail:
while (--i >= 0) while (--i >= 0) {
unregister_netdev(dev_nr[i]); unregister_netdev(dev_nr[i]);
free_netdev(dev_nr[i]);
}
kfree(dev_nr); kfree(dev_nr);
return -1; return -1;
} }
...@@ -1474,8 +1477,10 @@ static void __exit nr_exit(void) ...@@ -1474,8 +1477,10 @@ static void __exit nr_exit(void)
for (i = 0; i < nr_ndevs; i++) { for (i = 0; i < nr_ndevs; i++) {
struct net_device *dev = dev_nr[i]; struct net_device *dev = dev_nr[i];
if (dev) if (dev) {
unregister_netdev(dev); unregister_netdev(dev);
free_netdev(dev);
}
} }
kfree(dev_nr); kfree(dev_nr);
......
...@@ -204,7 +204,6 @@ void nr_setup(struct net_device *dev) ...@@ -204,7 +204,6 @@ void nr_setup(struct net_device *dev)
dev->hard_start_xmit = nr_xmit; dev->hard_start_xmit = nr_xmit;
dev->open = nr_open; dev->open = nr_open;
dev->stop = nr_close; dev->stop = nr_close;
dev->destructor = free_netdev;
dev->hard_header = nr_header; dev->hard_header = nr_header;
dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
......
...@@ -1481,7 +1481,7 @@ static int __init rose_proto_init(void) ...@@ -1481,7 +1481,7 @@ static int __init rose_proto_init(void)
rose_callsign = null_ax25_address; rose_callsign = null_ax25_address;
if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device)) { if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n"); printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
return -1; return -1;
} }
...@@ -1502,23 +1502,14 @@ static int __init rose_proto_init(void) ...@@ -1502,23 +1502,14 @@ static int __init rose_proto_init(void)
name, rose_setup); name, rose_setup);
if (!dev) { if (!dev) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n"); printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
while (--i >= 0) goto fail;
kfree(dev_rose[i]);
return -ENOMEM;
}
dev_rose[i] = dev;
} }
if (register_netdev(dev)) {
for (i = 0; i < rose_ndevs; i++) {
if (register_netdev(dev_rose[i])) {
printk(KERN_ERR "ROSE: netdevice regeistration failed\n"); printk(KERN_ERR "ROSE: netdevice regeistration failed\n");
while (--i >= 0) { free_netdev(dev);
unregister_netdev(dev_rose[i]); goto fail;
kfree(dev_rose[i]);
return -EIO;
}
} }
dev_rose[i] = dev;
} }
sock_register(&rose_family_ops); sock_register(&rose_family_ops);
...@@ -1541,6 +1532,13 @@ static int __init rose_proto_init(void) ...@@ -1541,6 +1532,13 @@ static int __init rose_proto_init(void)
proc_net_fops_create("rose_routes", S_IRUGO, &rose_routes_fops); proc_net_fops_create("rose_routes", S_IRUGO, &rose_routes_fops);
return 0; return 0;
fail:
while (--i >= 0) {
unregister_netdev(dev_rose[i]);
free_netdev(dev_rose[i]);
}
kfree(dev_rose);
return -ENOMEM;
} }
module_init(rose_proto_init); module_init(rose_proto_init);
......
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