diff options
| author | Florin Malita <fmalita@gmail.com> | 2006-10-10 16:46:30 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2006-10-16 20:09:48 -0400 |
| commit | 431aca5a18f15f61cc51c466073928c4f9565fe4 (patch) | |
| tree | 1ee40a5467e93060f37c271c7bd6d92096c6a045 | |
| parent | 8da81e52b743edac0bfbb7d0c1286f919b2f209b (diff) | |
[PATCH] airo.c: check returned values
create_proc_entry() can fail and return NULL in setup_proc_entry(), the
result must be checked before dereferencing. (Coverity ID 1443)
init_wifidev() & setup_proc_entry() can also fail in _init_airo_card().
This adds the checks & cleanup code and removes some whitespace.
Signed-off-by: Florin Malita <fmalita@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
| -rw-r--r-- | drivers/net/wireless/airo.c | 98 |
1 files changed, 72 insertions, 26 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 0a33c8a56e13..9d5427a6e609 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
| @@ -2897,6 +2897,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
| 2897 | goto err_out_map; | 2897 | goto err_out_map; |
| 2898 | } | 2898 | } |
| 2899 | ai->wifidev = init_wifidev(ai, dev); | 2899 | ai->wifidev = init_wifidev(ai, dev); |
| 2900 | if (!ai->wifidev) | ||
| 2901 | goto err_out_reg; | ||
| 2900 | 2902 | ||
| 2901 | set_bit(FLAG_REGISTERED,&ai->flags); | 2903 | set_bit(FLAG_REGISTERED,&ai->flags); |
| 2902 | airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x", | 2904 | airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x", |
| @@ -2908,11 +2910,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
| 2908 | for( i = 0; i < MAX_FIDS; i++ ) | 2910 | for( i = 0; i < MAX_FIDS; i++ ) |
| 2909 | ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); | 2911 | ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2); |
| 2910 | 2912 | ||
| 2911 | setup_proc_entry( dev, dev->priv ); /* XXX check for failure */ | 2913 | if (setup_proc_entry(dev, dev->priv) < 0) |
| 2914 | goto err_out_wifi; | ||
| 2915 | |||
| 2912 | netif_start_queue(dev); | 2916 | netif_start_queue(dev); |
| 2913 | SET_MODULE_OWNER(dev); | 2917 | SET_MODULE_OWNER(dev); |
| 2914 | return dev; | 2918 | return dev; |
| 2915 | 2919 | ||
| 2920 | err_out_wifi: | ||
| 2921 | unregister_netdev(ai->wifidev); | ||
| 2922 | free_netdev(ai->wifidev); | ||
| 2923 | err_out_reg: | ||
| 2924 | unregister_netdev(dev); | ||
| 2916 | err_out_map: | 2925 | err_out_map: |
| 2917 | if (test_bit(FLAG_MPI,&ai->flags) && pci) { | 2926 | if (test_bit(FLAG_MPI,&ai->flags) && pci) { |
| 2918 | pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); | 2927 | pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma); |
| @@ -4495,91 +4504,128 @@ static int setup_proc_entry( struct net_device *dev, | |||
| 4495 | apriv->proc_entry = create_proc_entry(apriv->proc_name, | 4504 | apriv->proc_entry = create_proc_entry(apriv->proc_name, |
| 4496 | S_IFDIR|airo_perm, | 4505 | S_IFDIR|airo_perm, |
| 4497 | airo_entry); | 4506 | airo_entry); |
| 4498 | apriv->proc_entry->uid = proc_uid; | 4507 | if (!apriv->proc_entry) |
| 4499 | apriv->proc_entry->gid = proc_gid; | 4508 | goto fail; |
| 4500 | apriv->proc_entry->owner = THIS_MODULE; | 4509 | apriv->proc_entry->uid = proc_uid; |
| 4510 | apriv->proc_entry->gid = proc_gid; | ||
| 4511 | apriv->proc_entry->owner = THIS_MODULE; | ||
| 4501 | 4512 | ||
| 4502 | /* Setup the StatsDelta */ | 4513 | /* Setup the StatsDelta */ |
| 4503 | entry = create_proc_entry("StatsDelta", | 4514 | entry = create_proc_entry("StatsDelta", |
| 4504 | S_IFREG | (S_IRUGO&proc_perm), | 4515 | S_IFREG | (S_IRUGO&proc_perm), |
| 4505 | apriv->proc_entry); | 4516 | apriv->proc_entry); |
| 4506 | entry->uid = proc_uid; | 4517 | if (!entry) |
| 4507 | entry->gid = proc_gid; | 4518 | goto fail_stats_delta; |
| 4519 | entry->uid = proc_uid; | ||
| 4520 | entry->gid = proc_gid; | ||
| 4508 | entry->data = dev; | 4521 | entry->data = dev; |
| 4509 | entry->owner = THIS_MODULE; | 4522 | entry->owner = THIS_MODULE; |
| 4510 | SETPROC_OPS(entry, proc_statsdelta_ops); | 4523 | SETPROC_OPS(entry, proc_statsdelta_ops); |
| 4511 | 4524 | ||
| 4512 | /* Setup the Stats */ | 4525 | /* Setup the Stats */ |
| 4513 | entry = create_proc_entry("Stats", | 4526 | entry = create_proc_entry("Stats", |
| 4514 | S_IFREG | (S_IRUGO&proc_perm), | 4527 | S_IFREG | (S_IRUGO&proc_perm), |
| 4515 | apriv->proc_entry); | 4528 | apriv->proc_entry); |
| 4516 | entry->uid = proc_uid; | 4529 | if (!entry) |
| 4517 | entry->gid = proc_gid; | 4530 | goto fail_stats; |
| 4531 | entry->uid = proc_uid; | ||
| 4532 | entry->gid = proc_gid; | ||
| 4518 | entry->data = dev; | 4533 | entry->data = dev; |
| 4519 | entry->owner = THIS_MODULE; | 4534 | entry->owner = THIS_MODULE; |
| 4520 | SETPROC_OPS(entry, proc_stats_ops); | 4535 | SETPROC_OPS(entry, proc_stats_ops); |
| 4521 | 4536 | ||
| 4522 | /* Setup the Status */ | 4537 | /* Setup the Status */ |
| 4523 | entry = create_proc_entry("Status", | 4538 | entry = create_proc_entry("Status", |
| 4524 | S_IFREG | (S_IRUGO&proc_perm), | 4539 | S_IFREG | (S_IRUGO&proc_perm), |
| 4525 | apriv->proc_entry); | 4540 | apriv->proc_entry); |
| 4526 | entry->uid = proc_uid; | 4541 | if (!entry) |
| 4527 | entry->gid = proc_gid; | 4542 | goto fail_status; |
| 4543 | entry->uid = proc_uid; | ||
| 4544 | entry->gid = proc_gid; | ||
| 4528 | entry->data = dev; | 4545 | entry->data = dev; |
| 4529 | entry->owner = THIS_MODULE; | 4546 | entry->owner = THIS_MODULE; |
| 4530 | SETPROC_OPS(entry, proc_status_ops); | 4547 | SETPROC_OPS(entry, proc_status_ops); |
| 4531 | 4548 | ||
| 4532 | /* Setup the Config */ | 4549 | /* Setup the Config */ |
| 4533 | entry = create_proc_entry("Config", | 4550 | entry = create_proc_entry("Config", |
| 4534 | S_IFREG | proc_perm, | 4551 | S_IFREG | proc_perm, |
| 4535 | apriv->proc_entry); | 4552 | apriv->proc_entry); |
| 4536 | entry->uid = proc_uid; | 4553 | if (!entry) |
| 4537 | entry->gid = proc_gid; | 4554 | goto fail_config; |
| 4555 | entry->uid = proc_uid; | ||
| 4556 | entry->gid = proc_gid; | ||
| 4538 | entry->data = dev; | 4557 | entry->data = dev; |
| 4539 | entry->owner = THIS_MODULE; | 4558 | entry->owner = THIS_MODULE; |
| 4540 | SETPROC_OPS(entry, proc_config_ops); | 4559 | SETPROC_OPS(entry, proc_config_ops); |
| 4541 | 4560 | ||
| 4542 | /* Setup the SSID */ | 4561 | /* Setup the SSID */ |
| 4543 | entry = create_proc_entry("SSID", | 4562 | entry = create_proc_entry("SSID", |
| 4544 | S_IFREG | proc_perm, | 4563 | S_IFREG | proc_perm, |
| 4545 | apriv->proc_entry); | 4564 | apriv->proc_entry); |
| 4546 | entry->uid = proc_uid; | 4565 | if (!entry) |
| 4547 | entry->gid = proc_gid; | 4566 | goto fail_ssid; |
| 4567 | entry->uid = proc_uid; | ||
| 4568 | entry->gid = proc_gid; | ||
| 4548 | entry->data = dev; | 4569 | entry->data = dev; |
| 4549 | entry->owner = THIS_MODULE; | 4570 | entry->owner = THIS_MODULE; |
| 4550 | SETPROC_OPS(entry, proc_SSID_ops); | 4571 | SETPROC_OPS(entry, proc_SSID_ops); |
| 4551 | 4572 | ||
| 4552 | /* Setup the APList */ | 4573 | /* Setup the APList */ |
| 4553 | entry = create_proc_entry("APList", | 4574 | entry = create_proc_entry("APList", |
| 4554 | S_IFREG | proc_perm, | 4575 | S_IFREG | proc_perm, |
| 4555 | apriv->proc_entry); | 4576 | apriv->proc_entry); |
| 4556 | entry->uid = proc_uid; | 4577 | if (!entry) |
| 4557 | entry->gid = proc_gid; | 4578 | goto fail_aplist; |
| 4579 | entry->uid = proc_uid; | ||
| 4580 | entry->gid = proc_gid; | ||
| 4558 | entry->data = dev; | 4581 | entry->data = dev; |
| 4559 | entry->owner = THIS_MODULE; | 4582 | entry->owner = THIS_MODULE; |
| 4560 | SETPROC_OPS(entry, proc_APList_ops); | 4583 | SETPROC_OPS(entry, proc_APList_ops); |
| 4561 | 4584 | ||
| 4562 | /* Setup the BSSList */ | 4585 | /* Setup the BSSList */ |
| 4563 | entry = create_proc_entry("BSSList", | 4586 | entry = create_proc_entry("BSSList", |
| 4564 | S_IFREG | proc_perm, | 4587 | S_IFREG | proc_perm, |
| 4565 | apriv->proc_entry); | 4588 | apriv->proc_entry); |
| 4589 | if (!entry) | ||
| 4590 | goto fail_bsslist; | ||
| 4566 | entry->uid = proc_uid; | 4591 | entry->uid = proc_uid; |
| 4567 | entry->gid = proc_gid; | 4592 | entry->gid = proc_gid; |
| 4568 | entry->data = dev; | 4593 | entry->data = dev; |
| 4569 | entry->owner = THIS_MODULE; | 4594 | entry->owner = THIS_MODULE; |
| 4570 | SETPROC_OPS(entry, proc_BSSList_ops); | 4595 | SETPROC_OPS(entry, proc_BSSList_ops); |
| 4571 | 4596 | ||
| 4572 | /* Setup the WepKey */ | 4597 | /* Setup the WepKey */ |
| 4573 | entry = create_proc_entry("WepKey", | 4598 | entry = create_proc_entry("WepKey", |
| 4574 | S_IFREG | proc_perm, | 4599 | S_IFREG | proc_perm, |
| 4575 | apriv->proc_entry); | 4600 | apriv->proc_entry); |
| 4576 | entry->uid = proc_uid; | 4601 | if (!entry) |
| 4577 | entry->gid = proc_gid; | 4602 | goto fail_wepkey; |
| 4603 | entry->uid = proc_uid; | ||
| 4604 | entry->gid = proc_gid; | ||
| 4578 | entry->data = dev; | 4605 | entry->data = dev; |
| 4579 | entry->owner = THIS_MODULE; | 4606 | entry->owner = THIS_MODULE; |
| 4580 | SETPROC_OPS(entry, proc_wepkey_ops); | 4607 | SETPROC_OPS(entry, proc_wepkey_ops); |
| 4581 | 4608 | ||
| 4582 | return 0; | 4609 | return 0; |
| 4610 | |||
| 4611 | fail_wepkey: | ||
| 4612 | remove_proc_entry("BSSList", apriv->proc_entry); | ||
| 4613 | fail_bsslist: | ||
| 4614 | remove_proc_entry("APList", apriv->proc_entry); | ||
| 4615 | fail_aplist: | ||
| 4616 | remove_proc_entry("SSID", apriv->proc_entry); | ||
| 4617 | fail_ssid: | ||
| 4618 | remove_proc_entry("Config", apriv->proc_entry); | ||
| 4619 | fail_config: | ||
| 4620 | remove_proc_entry("Status", apriv->proc_entry); | ||
| 4621 | fail_status: | ||
| 4622 | remove_proc_entry("Stats", apriv->proc_entry); | ||
| 4623 | fail_stats: | ||
| 4624 | remove_proc_entry("StatsDelta", apriv->proc_entry); | ||
| 4625 | fail_stats_delta: | ||
| 4626 | remove_proc_entry(apriv->proc_name, airo_entry); | ||
| 4627 | fail: | ||
| 4628 | return -ENOMEM; | ||
| 4583 | } | 4629 | } |
| 4584 | 4630 | ||
| 4585 | static int takedown_proc_entry( struct net_device *dev, | 4631 | static int takedown_proc_entry( struct net_device *dev, |
