diff mbox

[1/1] rsi: fix memory leak in debugfs entry and supported bands

Message ID 1474353784-9552-1-git-send-email-prameela.j04cs@gmail.com (mailing list archive)
State Superseded
Delegated to: Kalle Valo
Headers show

Commit Message

Prameela Rani Garnepudi Sept. 20, 2016, 6:43 a.m. UTC
From: Prameela Rani Garnepudi <prameela.garnepudi@redpinesignals.com>

Signed-off-by: Prameela Rani Garnepudi <prameela.garnepudi@redpinesignals.com>
Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
---
 drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Arend van Spriel Sept. 20, 2016, 12:27 p.m. UTC | #1
On 20-9-2016 8:43, Prameela Rani Garnepudi wrote:
> From: Prameela Rani Garnepudi <prameela.garnepudi@redpinesignals.com>
> 
> Signed-off-by: Prameela Rani Garnepudi <prameela.garnepudi@redpinesignals.com>
> Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>

Now you are exaggerating ;-) One of these should be sufficient. Instead
some descriptive text in the commit message is required. Describe the
scenario in which the memory is leaked, ie. during driver unload.

> ---
>  drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> index dbb2389..dc64532 100644
> --- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> +++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
> @@ -194,6 +194,7 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
>  void rsi_mac80211_detach(struct rsi_hw *adapter)
>  {
>  	struct ieee80211_hw *hw = adapter->hw;
> +	int i;
>  
>  	if (hw) {
>  		ieee80211_stop_queues(hw);
> @@ -201,7 +202,16 @@ void rsi_mac80211_detach(struct rsi_hw *adapter)
>  		ieee80211_free_hw(hw);
>  	}
>  
> +	for (i = 0; i < 2; i++) {

Use NUM_NL80211_BANDS instead of hardcoded value.

Regards,
Arend

> +		struct ieee80211_supported_band *sbands = &adapter->sbands[i];
> +
> +		kfree(sbands->channels);
> +	}
diff mbox

Patch

diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index dbb2389..dc64532 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -194,6 +194,7 @@  static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
 void rsi_mac80211_detach(struct rsi_hw *adapter)
 {
 	struct ieee80211_hw *hw = adapter->hw;
+	int i;
 
 	if (hw) {
 		ieee80211_stop_queues(hw);
@@ -201,7 +202,16 @@  void rsi_mac80211_detach(struct rsi_hw *adapter)
 		ieee80211_free_hw(hw);
 	}
 
+	for (i = 0; i < 2; i++) {
+		struct ieee80211_supported_band *sbands = &adapter->sbands[i];
+
+		kfree(sbands->channels);
+	}
+
+#ifdef CONFIG_RSI_DEBUGFS
 	rsi_remove_dbgfs(adapter);
+	kfree(adapter->dfsentry);
+#endif
 }
 EXPORT_SYMBOL_GPL(rsi_mac80211_detach);