diff options
author | Mohamed Abbas <mabbas@linux.intel.com> | 2008-04-03 19:05:24 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-04-08 16:44:42 -0400 |
commit | 03d29c684917860f90f897565b297c4aba713e0b (patch) | |
tree | e2084248721b540fcaa468b4c0c2d2961e03c6b8 /drivers | |
parent | fe00b5a5b7e29180e427e58b3d0a185d1dd3f105 (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')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-rfkill.c | 31 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-rfkill.h | 2 |
3 files changed, 22 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f12230780555..d8a226e68ed1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -256,9 +256,13 @@ EXPORT_SYMBOL(iwl_setup); | |||
256 | int iwlcore_low_level_notify(struct iwl_priv *priv, | 256 | int iwlcore_low_level_notify(struct iwl_priv *priv, |
257 | enum iwlcore_card_notify notify) | 257 | enum iwlcore_card_notify notify) |
258 | { | 258 | { |
259 | int ret; | ||
259 | switch (notify) { | 260 | switch (notify) { |
260 | case IWLCORE_INIT_EVT: | 261 | case IWLCORE_INIT_EVT: |
261 | iwl_rfkill_init(priv); | 262 | ret = iwl_rfkill_init(priv); |
263 | if (ret) | ||
264 | IWL_ERROR("Unable to initialize RFKILL system. " | ||
265 | "Ignoring error: %d\n", ret); | ||
262 | break; | 266 | break; |
263 | case IWLCORE_START_EVT: | 267 | case IWLCORE_START_EVT: |
264 | break; | 268 | break; |
@@ -266,7 +270,6 @@ int iwlcore_low_level_notify(struct iwl_priv *priv, | |||
266 | break; | 270 | break; |
267 | case IWLCORE_REMOVE_EVT: | 271 | case IWLCORE_REMOVE_EVT: |
268 | iwl_rfkill_unregister(priv); | 272 | iwl_rfkill_unregister(priv); |
269 | iwl_rfkill_free(priv); | ||
270 | break; | 273 | break; |
271 | } | 274 | } |
272 | 275 | ||
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 | ||
117 | unregister_rfkill: | 125 | unregister_rfkill: |
118 | rfkill_unregister(priv->rfkill_mngr.rfkill); | 126 | rfkill_unregister(priv->rfkill_mngr.rfkill); |
127 | priv->rfkill_mngr.rfkill = NULL; | ||
119 | 128 | ||
120 | free_input_dev: | 129 | free_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 | ||
124 | freed_rfkill: | 133 | freed_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 | ||
128 | error: | 138 | error: |
139 | IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n"); | ||
129 | return ret; | 140 | return ret; |
130 | } | 141 | } |
131 | EXPORT_SYMBOL(iwl_rfkill_init); | 142 | EXPORT_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 | } | ||
142 | EXPORT_SYMBOL(iwl_rfkill_unregister); | ||
143 | 152 | ||
144 | 153 | priv->rfkill_mngr.input_dev = NULL; | |
145 | void 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 | } |
153 | EXPORT_SYMBOL(iwl_rfkill_free); | 156 | EXPORT_SYMBOL(iwl_rfkill_unregister); |
154 | 157 | ||
155 | /* set rf-kill to the right state. */ | 158 | /* set rf-kill to the right state. */ |
156 | void iwl_rfkill_set_hw_state(struct iwl_priv *priv) | 159 | void iwl_rfkill_set_hw_state(struct iwl_priv *priv) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-rfkill.h b/drivers/net/wireless/iwlwifi/iwl-rfkill.h index a5cbc5ab45d9..e7aa51a1db18 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rfkill.h +++ b/drivers/net/wireless/iwlwifi/iwl-rfkill.h | |||
@@ -41,12 +41,10 @@ struct iwl_rfkill_mngr { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | void iwl_rfkill_set_hw_state(struct iwl_priv *priv); | 43 | void iwl_rfkill_set_hw_state(struct iwl_priv *priv); |
44 | void iwl_rfkill_free(struct iwl_priv *priv); | ||
45 | void iwl_rfkill_unregister(struct iwl_priv *priv); | 44 | void iwl_rfkill_unregister(struct iwl_priv *priv); |
46 | int iwl_rfkill_init(struct iwl_priv *priv); | 45 | int iwl_rfkill_init(struct iwl_priv *priv); |
47 | #else | 46 | #else |
48 | static inline void iwl_rfkill_set_hw_state(struct iwl_priv *priv) {} | 47 | static inline void iwl_rfkill_set_hw_state(struct iwl_priv *priv) {} |
49 | static inline void iwl_rfkill_free(struct iwl_priv *priv) {} | ||
50 | static inline void iwl_rfkill_unregister(struct iwl_priv *priv) {} | 48 | static inline void iwl_rfkill_unregister(struct iwl_priv *priv) {} |
51 | static inline int iwl_rfkill_init(struct iwl_priv *priv) { return 0; } | 49 | static inline int iwl_rfkill_init(struct iwl_priv *priv) { return 0; } |
52 | #endif | 50 | #endif |