summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/iwlwifi/iwl-rfkill.c
diff options
context:
space:
mode:
authorMohamed Abbas <mabbas@linux.intel.com>2008-04-04 03:05:24 +0400
committerJohn W. Linville <linville@tuxdriver.com>2008-04-09 00:44:42 +0400
commit03d29c684917860f90f897565b297c4aba713e0b (patch)
treee2084248721b540fcaa468b4c0c2d2961e03c6b8 /drivers/net/wireless/iwlwifi/iwl-rfkill.c
parentfe00b5a5b7e29180e427e58b3d0a185d1dd3f105 (diff)
downloadlinux-03d29c684917860f90f897565b297c4aba713e0b.tar.xz
iwlwifi: fix rfkill memory error
Do not free reference to device twice. After rfkill registration succeeds we only need to call rfkill_unregister() and not rfkill_free(). Also add some debugging. Signed-off-by: Mohamed Abbas <mabbas@linux.intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-rfkill.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rfkill.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-rfkill.c b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
index 308d69b18404..8f38c24491cd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rfkill.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
@@ -75,8 +75,10 @@ int iwl_rfkill_init(struct iwl_priv *priv)
BUG_ON(device == NULL);
+ IWL_DEBUG_RF_KILL("Initializing RFKILL.\n");
priv->rfkill_mngr.rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
if (!priv->rfkill_mngr.rfkill) {
+ IWL_ERROR("Unable to allocate rfkill device.\n");
ret = -ENOMEM;
goto error;
}
@@ -92,6 +94,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
priv->rfkill_mngr.input_dev = input_allocate_device();
if (!priv->rfkill_mngr.input_dev) {
+ IWL_ERROR("Unable to allocate rfkill input device.\n");
ret = -ENOMEM;
goto freed_rfkill;
}
@@ -105,27 +108,35 @@ int iwl_rfkill_init(struct iwl_priv *priv)
set_bit(KEY_WLAN, priv->rfkill_mngr.input_dev->keybit);
ret = rfkill_register(priv->rfkill_mngr.rfkill);
- if (ret)
+ if (ret) {
+ IWL_ERROR("Unable to register rfkill: %d\n", ret);
goto free_input_dev;
+ }
ret = input_register_device(priv->rfkill_mngr.input_dev);
- if (ret)
+ if (ret) {
+ IWL_ERROR("Unable to register rfkill input device: %d\n", ret);
goto unregister_rfkill;
+ }
+ IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
return ret;
unregister_rfkill:
rfkill_unregister(priv->rfkill_mngr.rfkill);
+ priv->rfkill_mngr.rfkill = NULL;
free_input_dev:
input_free_device(priv->rfkill_mngr.input_dev);
priv->rfkill_mngr.input_dev = NULL;
freed_rfkill:
- rfkill_free(priv->rfkill_mngr.rfkill);
+ if (priv->rfkill_mngr.rfkill != NULL)
+ rfkill_free(priv->rfkill_mngr.rfkill);
priv->rfkill_mngr.rfkill = NULL;
error:
+ IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
return ret;
}
EXPORT_SYMBOL(iwl_rfkill_init);
@@ -138,19 +149,11 @@ void iwl_rfkill_unregister(struct iwl_priv *priv)
if (priv->rfkill_mngr.rfkill)
rfkill_unregister(priv->rfkill_mngr.rfkill);
-}
-EXPORT_SYMBOL(iwl_rfkill_unregister);
-
-void iwl_rfkill_free(struct iwl_priv *priv)
-{
- if (priv->rfkill_mngr.input_dev)
- input_free_device(priv->rfkill_mngr.input_dev);
-
- if (priv->rfkill_mngr.rfkill)
- rfkill_free(priv->rfkill_mngr.rfkill);
+ priv->rfkill_mngr.input_dev = NULL;
+ priv->rfkill_mngr.rfkill = NULL;
}
-EXPORT_SYMBOL(iwl_rfkill_free);
+EXPORT_SYMBOL(iwl_rfkill_unregister);
/* set rf-kill to the right state. */
void iwl_rfkill_set_hw_state(struct iwl_priv *priv)