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