aboutsummaryrefslogtreecommitdiffstats
path: root/net/rose/af_rose.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2005-09-27 18:44:36 -0400
committerDavid S. Miller <davem@davemloft.net>2005-09-27 18:44:36 -0400
commita83cd2cc90bd9390cf03cd40bba204d9ed520633 (patch)
treeb5c829bd75b2252a7fe0232c7625035783a2eaea /net/rose/af_rose.c
parent70ff3b66d79c5110e533f3f2aea1a5b2fc5f8d90 (diff)
[ROSE]: check rose_ndevs earlier
* Don't bother with proto registering if rose_ndevs is bad. * Make escape structure more coherent. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rose/af_rose.c')
-rw-r--r--net/rose/af_rose.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index dbfb0e3dc798..0f96565a64ec 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1472,24 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62
1472static int __init rose_proto_init(void) 1472static int __init rose_proto_init(void)
1473{ 1473{
1474 int i; 1474 int i;
1475 int rc = proto_register(&rose_proto, 0); 1475 int rc;
1476 1476
1477 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1478 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1479 rc = -EINVAL;
1480 goto out;
1481 }
1482
1483 rc = proto_register(&rose_proto, 0);
1477 if (rc != 0) 1484 if (rc != 0)
1478 goto out; 1485 goto out;
1479 1486
1480 rose_callsign = null_ax25_address; 1487 rose_callsign = null_ax25_address;
1481 1488
1482 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1483 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1484 proto_unregister(&rose_proto);
1485 return -EINVAL;
1486 }
1487
1488 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); 1489 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
1489 if (dev_rose == NULL) { 1490 if (dev_rose == NULL) {
1490 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); 1491 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
1491 proto_unregister(&rose_proto); 1492 rc = -ENOMEM;
1492 return -ENOMEM; 1493 goto out_proto_unregister;
1493 } 1494 }
1494 1495
1495 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); 1496 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*));
@@ -1540,6 +1541,7 @@ fail:
1540 free_netdev(dev_rose[i]); 1541 free_netdev(dev_rose[i]);
1541 } 1542 }
1542 kfree(dev_rose); 1543 kfree(dev_rose);
1544out_proto_unregister:
1543 proto_unregister(&rose_proto); 1545 proto_unregister(&rose_proto);
1544 goto out; 1546 goto out;
1545} 1547}