Commit a83cd2cc authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

[ROSE]: check rose_ndevs earlier

* Don't bother with proto registering if rose_ndevs is bad.
* Make escape structure more coherent.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 70ff3b66
...@@ -1472,24 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62 ...@@ -1472,24 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62
static int __init rose_proto_init(void) static int __init rose_proto_init(void)
{ {
int i; int i;
int rc = proto_register(&rose_proto, 0); int rc;
if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
rc = -EINVAL;
goto out;
}
rc = proto_register(&rose_proto, 0);
if (rc != 0) if (rc != 0)
goto out; goto out;
rose_callsign = null_ax25_address; rose_callsign = null_ax25_address;
if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
proto_unregister(&rose_proto);
return -EINVAL;
}
dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
if (dev_rose == NULL) { if (dev_rose == NULL) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
proto_unregister(&rose_proto); rc = -ENOMEM;
return -ENOMEM; goto out_proto_unregister;
} }
memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*));
...@@ -1540,6 +1541,7 @@ fail: ...@@ -1540,6 +1541,7 @@ fail:
free_netdev(dev_rose[i]); free_netdev(dev_rose[i]);
} }
kfree(dev_rose); kfree(dev_rose);
out_proto_unregister:
proto_unregister(&rose_proto); proto_unregister(&rose_proto);
goto out; goto out;
} }
......
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