[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>
This commit is contained in:
committed by
John W. Linville
parent
8da81e52b7
commit
431aca5a18
@@ -2897,6 +2897,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
|
|||||||
goto err_out_map;
|
goto err_out_map;
|
||||||
}
|
}
|
||||||
ai->wifidev = init_wifidev(ai, dev);
|
ai->wifidev = init_wifidev(ai, dev);
|
||||||
|
if (!ai->wifidev)
|
||||||
|
goto err_out_reg;
|
||||||
|
|
||||||
set_bit(FLAG_REGISTERED,&ai->flags);
|
set_bit(FLAG_REGISTERED,&ai->flags);
|
||||||
airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
|
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,
|
|||||||
for( i = 0; i < MAX_FIDS; i++ )
|
for( i = 0; i < MAX_FIDS; i++ )
|
||||||
ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
|
ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
|
||||||
|
|
||||||
setup_proc_entry( dev, dev->priv ); /* XXX check for failure */
|
if (setup_proc_entry(dev, dev->priv) < 0)
|
||||||
|
goto err_out_wifi;
|
||||||
|
|
||||||
netif_start_queue(dev);
|
netif_start_queue(dev);
|
||||||
SET_MODULE_OWNER(dev);
|
SET_MODULE_OWNER(dev);
|
||||||
return dev;
|
return dev;
|
||||||
|
|
||||||
|
err_out_wifi:
|
||||||
|
unregister_netdev(ai->wifidev);
|
||||||
|
free_netdev(ai->wifidev);
|
||||||
|
err_out_reg:
|
||||||
|
unregister_netdev(dev);
|
||||||
err_out_map:
|
err_out_map:
|
||||||
if (test_bit(FLAG_MPI,&ai->flags) && pci) {
|
if (test_bit(FLAG_MPI,&ai->flags) && pci) {
|
||||||
pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
|
pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
|
||||||
@@ -4495,6 +4504,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
apriv->proc_entry = create_proc_entry(apriv->proc_name,
|
apriv->proc_entry = create_proc_entry(apriv->proc_name,
|
||||||
S_IFDIR|airo_perm,
|
S_IFDIR|airo_perm,
|
||||||
airo_entry);
|
airo_entry);
|
||||||
|
if (!apriv->proc_entry)
|
||||||
|
goto fail;
|
||||||
apriv->proc_entry->uid = proc_uid;
|
apriv->proc_entry->uid = proc_uid;
|
||||||
apriv->proc_entry->gid = proc_gid;
|
apriv->proc_entry->gid = proc_gid;
|
||||||
apriv->proc_entry->owner = THIS_MODULE;
|
apriv->proc_entry->owner = THIS_MODULE;
|
||||||
@@ -4503,6 +4514,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("StatsDelta",
|
entry = create_proc_entry("StatsDelta",
|
||||||
S_IFREG | (S_IRUGO&proc_perm),
|
S_IFREG | (S_IRUGO&proc_perm),
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_stats_delta;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4513,6 +4526,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("Stats",
|
entry = create_proc_entry("Stats",
|
||||||
S_IFREG | (S_IRUGO&proc_perm),
|
S_IFREG | (S_IRUGO&proc_perm),
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_stats;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4523,6 +4538,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("Status",
|
entry = create_proc_entry("Status",
|
||||||
S_IFREG | (S_IRUGO&proc_perm),
|
S_IFREG | (S_IRUGO&proc_perm),
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_status;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4533,6 +4550,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("Config",
|
entry = create_proc_entry("Config",
|
||||||
S_IFREG | proc_perm,
|
S_IFREG | proc_perm,
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_config;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4543,6 +4562,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("SSID",
|
entry = create_proc_entry("SSID",
|
||||||
S_IFREG | proc_perm,
|
S_IFREG | proc_perm,
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_ssid;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4553,6 +4574,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("APList",
|
entry = create_proc_entry("APList",
|
||||||
S_IFREG | proc_perm,
|
S_IFREG | proc_perm,
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_aplist;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4563,6 +4586,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("BSSList",
|
entry = create_proc_entry("BSSList",
|
||||||
S_IFREG | proc_perm,
|
S_IFREG | proc_perm,
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_bsslist;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4573,6 +4598,8 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
entry = create_proc_entry("WepKey",
|
entry = create_proc_entry("WepKey",
|
||||||
S_IFREG | proc_perm,
|
S_IFREG | proc_perm,
|
||||||
apriv->proc_entry);
|
apriv->proc_entry);
|
||||||
|
if (!entry)
|
||||||
|
goto fail_wepkey;
|
||||||
entry->uid = proc_uid;
|
entry->uid = proc_uid;
|
||||||
entry->gid = proc_gid;
|
entry->gid = proc_gid;
|
||||||
entry->data = dev;
|
entry->data = dev;
|
||||||
@@ -4580,6 +4607,25 @@ static int setup_proc_entry( struct net_device *dev,
|
|||||||
SETPROC_OPS(entry, proc_wepkey_ops);
|
SETPROC_OPS(entry, proc_wepkey_ops);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail_wepkey:
|
||||||
|
remove_proc_entry("BSSList", apriv->proc_entry);
|
||||||
|
fail_bsslist:
|
||||||
|
remove_proc_entry("APList", apriv->proc_entry);
|
||||||
|
fail_aplist:
|
||||||
|
remove_proc_entry("SSID", apriv->proc_entry);
|
||||||
|
fail_ssid:
|
||||||
|
remove_proc_entry("Config", apriv->proc_entry);
|
||||||
|
fail_config:
|
||||||
|
remove_proc_entry("Status", apriv->proc_entry);
|
||||||
|
fail_status:
|
||||||
|
remove_proc_entry("Stats", apriv->proc_entry);
|
||||||
|
fail_stats:
|
||||||
|
remove_proc_entry("StatsDelta", apriv->proc_entry);
|
||||||
|
fail_stats_delta:
|
||||||
|
remove_proc_entry(apriv->proc_name, airo_entry);
|
||||||
|
fail:
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int takedown_proc_entry( struct net_device *dev,
|
static int takedown_proc_entry( struct net_device *dev,
|
||||||
|
Reference in New Issue
Block a user