aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-rfkill.c
diff options
context:
space:
mode:
authorMohamed Abbas <mabbas@linux.intel.com>2008-04-03 19:05:24 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-04-08 16:44:42 -0400
commit03d29c684917860f90f897565b297c4aba713e0b (patch)
treee2084248721b540fcaa468b4c0c2d2961e03c6b8 /drivers/net/wireless/iwlwifi/iwl-rfkill.c
parentfe00b5a5b7e29180e427e58b3d0a185d1dd3f105 (diff)
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)
75 75
76 BUG_ON(device == NULL); 76 BUG_ON(device == NULL);
77 77
78 IWL_DEBUG_RF_KILL("Initializing RFKILL.\n");
78 priv->rfkill_mngr.rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); 79 priv->rfkill_mngr.rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
79 if (!priv->rfkill_mngr.rfkill) { 80 if (!priv->rfkill_mngr.rfkill) {
81 IWL_ERROR("Unable to allocate rfkill device.\n");
80 ret = -ENOMEM; 82 ret = -ENOMEM;
81 goto error; 83 goto error;
82 } 84 }
@@ -92,6 +94,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
92 94
93 priv->rfkill_mngr.input_dev = input_allocate_device(); 95 priv->rfkill_mngr.input_dev = input_allocate_device();
94 if (!priv->rfkill_mngr.input_dev) { 96 if (!priv->rfkill_mngr.input_dev) {
97 IWL_ERROR("Unable to allocate rfkill input device.\n");
95 ret = -ENOMEM; 98 ret = -ENOMEM;
96 goto freed_rfkill; 99 goto freed_rfkill;
97 } 100 }
@@ -105,27 +108,35 @@ int iwl_rfkill_init(struct iwl_priv *priv)
105 set_bit(KEY_WLAN, priv->rfkill_mngr.input_dev->keybit); 108 set_bit(KEY_WLAN, priv->rfkill_mngr.input_dev->keybit);
106 109
107 ret = rfkill_register(priv->rfkill_mngr.rfkill); 110 ret = rfkill_register(priv->rfkill_mngr.rfkill);
108 if (ret) 111 if (ret) {
112 IWL_ERROR("Unable to register rfkill: %d\n", ret);
109 goto free_input_dev; 113 goto free_input_dev;
114 }
110 115
111 ret = input_register_device(priv->rfkill_mngr.input_dev); 116 ret = input_register_device(priv->rfkill_mngr.input_dev);
112 if (ret) 117 if (ret) {
118 IWL_ERROR("Unable to register rfkill input device: %d\n", ret);
113 goto unregister_rfkill; 119 goto unregister_rfkill;
120 }
114 121
122 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
115 return ret; 123 return ret;
116 124
117unregister_rfkill: 125unregister_rfkill:
118 rfkill_unregister(priv->rfkill_mngr.rfkill); 126 rfkill_unregister(priv->rfkill_mngr.rfkill);
127 priv->rfkill_mngr.rfkill = NULL;
119 128
120free_input_dev: 129free_input_dev:
121 input_free_device(priv->rfkill_mngr.input_dev); 130 input_free_device(priv->rfkill_mngr.input_dev);
122 priv->rfkill_mngr.input_dev = NULL; 131 priv->rfkill_mngr.input_dev = NULL;
123 132
124freed_rfkill: 133freed_rfkill:
125 rfkill_free(priv->rfkill_mngr.rfkill); 134 if (priv->rfkill_mngr.rfkill != NULL)
135 rfkill_free(priv->rfkill_mngr.rfkill);
126 priv->rfkill_mngr.rfkill = NULL; 136 priv->rfkill_mngr.rfkill = NULL;
127 137
128error: 138error:
139 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
129 return ret; 140 return ret;
130} 141}
131EXPORT_SYMBOL(iwl_rfkill_init); 142EXPORT_SYMBOL(iwl_rfkill_init);
@@ -138,19 +149,11 @@ void iwl_rfkill_unregister(struct iwl_priv *priv)
138 149
139 if (priv->rfkill_mngr.rfkill) 150 if (priv->rfkill_mngr.rfkill)
140 rfkill_unregister(priv->rfkill_mngr.rfkill); 151 rfkill_unregister(priv->rfkill_mngr.rfkill);
141}
142EXPORT_SYMBOL(iwl_rfkill_unregister);
143 152
144 153 priv->rfkill_mngr.input_dev = NULL;
145void iwl_rfkill_free(struct iwl_priv *priv) 154 priv->rfkill_mngr.rfkill = NULL;
146{
147 if (priv->rfkill_mngr.input_dev)
148 input_free_device(priv->rfkill_mngr.input_dev);
149
150 if (priv->rfkill_mngr.rfkill)
151 rfkill_free(priv->rfkill_mngr.rfkill);
152} 155}
153EXPORT_SYMBOL(iwl_rfkill_free); 156EXPORT_SYMBOL(iwl_rfkill_unregister);
154 157
155/* set rf-kill to the right state. */ 158/* set rf-kill to the right state. */
156void iwl_rfkill_set_hw_state(struct iwl_priv *priv) 159void iwl_rfkill_set_hw_state(struct iwl_priv *priv)