From: Michal Kazior <michal.kazior@tieto.com> To: <ath10k@lists.infradead.org> Cc: <linux-wireless@vger.kernel.org>, Michal Kazior <michal.kazior@tieto.com> Subject: [PATCH 2/3] ath10k: fix memleak in mac setup Date: Thu, 18 Jul 2013 08:33:12 +0200 [thread overview] Message-ID: <1374129193-3533-3-git-send-email-michal.kazior@tieto.com> (raw) In-Reply-To: <1374129193-3533-1-git-send-email-michal.kazior@tieto.com> 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> --- drivers/net/wireless/ath/ath10k/mac.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 5082503..3d0f876 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -3025,8 +3025,10 @@ int ath10k_mac_register(struct ath10k *ar) channels = kmemdup(ath10k_2ghz_channels, sizeof(ath10k_2ghz_channels), GFP_KERNEL); - if (!channels) - return -ENOMEM; + if (!channels) { + ret = -ENOMEM; + goto err_free; + } band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels); @@ -3045,11 +3047,8 @@ int ath10k_mac_register(struct ath10k *ar) sizeof(ath10k_5ghz_channels), GFP_KERNEL); if (!channels) { - if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) { - band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; - kfree(band->channels); - } - return -ENOMEM; + ret = -ENOMEM; + goto err_free; } band = &ar->mac.sbands[IEEE80211_BAND_5GHZ]; @@ -3113,25 +3112,30 @@ int ath10k_mac_register(struct ath10k *ar) ath10k_reg_notifier); if (ret) { ath10k_err("Regulatory initialization failed\n"); - return ret; + goto err_free; } ret = ieee80211_register_hw(ar->hw); if (ret) { ath10k_err("ieee80211 registration failed: %d\n", ret); - return ret; + goto err_free; } if (!ath_is_world_regd(&ar->ath_common.regulatory)) { ret = regulatory_hint(ar->hw->wiphy, ar->ath_common.regulatory.alpha2); if (ret) - goto exit; + goto err_unregister; } return 0; -exit: + +err_unregister: ieee80211_unregister_hw(ar->hw); +err_free: + kfree(ar->mac.sbands[IEEE80211_BAND_2GHZ].channels); + kfree(ar->mac.sbands[IEEE80211_BAND_5GHZ].channels); + return ret; } -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Michal Kazior <michal.kazior@tieto.com> To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior <michal.kazior@tieto.com> Subject: [PATCH 2/3] ath10k: fix memleak in mac setup Date: Thu, 18 Jul 2013 08:33:12 +0200 [thread overview] Message-ID: <1374129193-3533-3-git-send-email-michal.kazior@tieto.com> (raw) In-Reply-To: <1374129193-3533-1-git-send-email-michal.kazior@tieto.com> 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> --- drivers/net/wireless/ath/ath10k/mac.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 5082503..3d0f876 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -3025,8 +3025,10 @@ int ath10k_mac_register(struct ath10k *ar) channels = kmemdup(ath10k_2ghz_channels, sizeof(ath10k_2ghz_channels), GFP_KERNEL); - if (!channels) - return -ENOMEM; + if (!channels) { + ret = -ENOMEM; + goto err_free; + } band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; band->n_channels = ARRAY_SIZE(ath10k_2ghz_channels); @@ -3045,11 +3047,8 @@ int ath10k_mac_register(struct ath10k *ar) sizeof(ath10k_5ghz_channels), GFP_KERNEL); if (!channels) { - if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) { - band = &ar->mac.sbands[IEEE80211_BAND_2GHZ]; - kfree(band->channels); - } - return -ENOMEM; + ret = -ENOMEM; + goto err_free; } band = &ar->mac.sbands[IEEE80211_BAND_5GHZ]; @@ -3113,25 +3112,30 @@ int ath10k_mac_register(struct ath10k *ar) ath10k_reg_notifier); if (ret) { ath10k_err("Regulatory initialization failed\n"); - return ret; + goto err_free; } ret = ieee80211_register_hw(ar->hw); if (ret) { ath10k_err("ieee80211 registration failed: %d\n", ret); - return ret; + goto err_free; } if (!ath_is_world_regd(&ar->ath_common.regulatory)) { ret = regulatory_hint(ar->hw->wiphy, ar->ath_common.regulatory.alpha2); if (ret) - goto exit; + goto err_unregister; } return 0; -exit: + +err_unregister: ieee80211_unregister_hw(ar->hw); +err_free: + kfree(ar->mac.sbands[IEEE80211_BAND_2GHZ].channels); + kfree(ar->mac.sbands[IEEE80211_BAND_5GHZ].channels); + return ret; } -- 1.7.9.5 _______________________________________________ ath10k mailing list ath10k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath10k
next prev parent reply other threads:[~2013-07-18 6:33 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-18 6:33 [PATCH 0/3] ath10k: fixes Michal Kazior 2013-07-18 6:33 ` Michal Kazior 2013-07-18 6:33 ` [PATCH 1/3] ath10k: prevent HTC from being used after stopping Michal Kazior 2013-07-18 6:33 ` Michal Kazior 2013-07-19 11:04 ` Kalle Valo 2013-07-19 11:04 ` Kalle Valo 2013-07-19 11:08 ` Michal Kazior 2013-07-19 11:08 ` Michal Kazior 2013-07-19 11:44 ` Kalle Valo 2013-07-19 11:44 ` Kalle Valo 2013-07-18 6:33 ` Michal Kazior [this message] 2013-07-18 6:33 ` [PATCH 2/3] ath10k: fix memleak in mac setup Michal Kazior 2013-07-18 6:33 ` [PATCH 3/3] ath10k: fix rts/fragmentation threshold setup Michal Kazior 2013-07-18 6:33 ` Michal Kazior 2013-07-19 11:07 ` [PATCH 0/3] ath10k: fixes Kalle Valo 2013-07-19 11:07 ` Kalle Valo 2013-07-19 11:10 ` Michal Kazior 2013-07-19 11:10 ` Michal Kazior 2013-07-19 11:43 ` Kalle Valo 2013-07-19 11:43 ` Kalle Valo 2013-07-22 12:13 ` [PATCH v2 0/4] " Michal Kazior 2013-07-22 12:13 ` Michal Kazior 2013-07-22 12:13 ` [PATCH v2 1/4] ath10k: prevent HTC from being used after stopping Michal Kazior 2013-07-22 12:13 ` Michal Kazior 2013-07-22 12:13 ` [PATCH v2 2/4] ath10k: don't reset HTC endpoints unnecessarily Michal Kazior 2013-07-22 12:13 ` Michal Kazior 2013-07-23 8:46 ` Kalle Valo 2013-07-23 8:46 ` Kalle Valo 2013-07-22 12:13 ` [PATCH v2 3/4] ath10k: fix memleak in mac setup Michal Kazior 2013-07-22 12:13 ` Michal Kazior 2013-07-22 12:13 ` [PATCH v2 4/4] ath10k: fix rts/fragmentation threshold setup Michal Kazior 2013-07-22 12:13 ` Michal Kazior 2013-07-23 8:47 ` [PATCH v2 0/4] ath10k: fixes Kalle Valo 2013-07-23 8:47 ` Kalle Valo
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1374129193-3533-3-git-send-email-michal.kazior@tieto.com \ --to=michal.kazior@tieto.com \ --cc=ath10k@lists.infradead.org \ --cc=linux-wireless@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.