aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath10k
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2013-07-22 08:13:30 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2013-07-30 11:01:21 -0400
commitd6015b27f7dd6e167cd90b590dc9ed5dfbc68086 (patch)
tree1be9b53fcc932d37c4338707f5feff2ee7ae2e7b /drivers/net/wireless/ath/ath10k
parent21bf9112b596cb91e4f63de859ea514f081031fd (diff)
ath10k: fix memleak in mac setup
In some cases channel arrays were never freed. The patch also unifies error handling in the mac setup function. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath10k')
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 07e5f7d40466..6144b3bf3da5 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3225,8 +3225,10 @@ int ath10k_mac_register(struct ath10k *ar)
3225 channels = kmemdup(ath10k_2ghz_channels, 3225 channels = kmemdup(ath10k_2ghz_channels,
3226 sizeof(ath10k_2ghz_channels), 3226 sizeof(ath10k_2ghz_channels),
3227 GFP_KERNEL); 3227 GFP_KERNEL);
3228 if (!channels) 3228 if (!channels) {
3229 return -ENOMEM; 3229 ret = -ENOMEM;
3230 goto err_free;
3231 }
3230 3232
3231 band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; 3233 band = &ar->mac.sbands[IEEE80211_BAND_2GHZ];
3232 band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels); 3234 band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels);
@@ -3245,11 +3247,8 @@ int ath10k_mac_register(struct ath10k *ar)
3245 sizeof(ath10k_5ghz_channels), 3247 sizeof(ath10k_5ghz_channels),
3246 GFP_KERNEL); 3248 GFP_KERNEL);
3247 if (!channels) { 3249 if (!channels) {
3248 if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) { 3250 ret = -ENOMEM;
3249 band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; 3251 goto err_free;
3250 kfree(band->channels);
3251 }
3252 return -ENOMEM;
3253 } 3252 }
3254 3253
3255 band = &ar->mac.sbands[IEEE80211_BAND_5GHZ]; 3254 band = &ar->mac.sbands[IEEE80211_BAND_5GHZ];
@@ -3313,25 +3312,30 @@ int ath10k_mac_register(struct ath10k *ar)
3313 ath10k_reg_notifier); 3312 ath10k_reg_notifier);
3314 if (ret) { 3313 if (ret) {
3315 ath10k_err("Regulatory initialization failed\n"); 3314 ath10k_err("Regulatory initialization failed\n");
3316 return ret; 3315 goto err_free;
3317 } 3316 }
3318 3317
3319 ret = ieee80211_register_hw(ar->hw); 3318 ret = ieee80211_register_hw(ar->hw);
3320 if (ret) { 3319 if (ret) {
3321 ath10k_err("ieee80211 registration failed: %d\n", ret); 3320 ath10k_err("ieee80211 registration failed: %d\n", ret);
3322 return ret; 3321 goto err_free;
3323 } 3322 }
3324 3323
3325 if (!ath_is_world_regd(&ar->ath_common.regulatory)) { 3324 if (!ath_is_world_regd(&ar->ath_common.regulatory)) {
3326 ret = regulatory_hint(ar->hw->wiphy, 3325 ret = regulatory_hint(ar->hw->wiphy,
3327 ar->ath_common.regulatory.alpha2); 3326 ar->ath_common.regulatory.alpha2);
3328 if (ret) 3327 if (ret)
3329 goto exit; 3328 goto err_unregister;
3330 } 3329 }
3331 3330
3332 return 0; 3331 return 0;
3333exit: 3332
3333err_unregister:
3334 ieee80211_unregister_hw(ar->hw); 3334 ieee80211_unregister_hw(ar->hw);
3335err_free:
3336 kfree(ar->mac.sbands[IEEE80211_BAND_2GHZ].channels);
3337 kfree(ar->mac.sbands[IEEE80211_BAND_5GHZ].channels);
3338
3335 return ret; 3339 return ret;
3336} 3340}
3337 3341