public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: mt7915: fix memory leak in mt7915_rate_txpower_get
@ 2023-01-03 10:15 Lorenzo Bianconi
  2023-01-16 12:16 ` Lorenzo Bianconi
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2023-01-03 10:15 UTC (permalink / raw)
  To: nbd; +Cc: lorenzo.bianconi, linux-wireless

Fix possible memory leak in mt7915_rate_txpower_get routine if
mt7915_mcu_get_txpower_sku() fails.

Fixes: e3296759f347 ("wifi: mt76: mt7915: enable per bandwidth power limit support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index fb46c2c1784f..4730508652af 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -990,14 +990,14 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
 	char *buf;
 	u32 reg;
 
-	buf = kzalloc(sz, GFP_KERNEL);
-	if (!buf)
-		return -ENOMEM;
-
 	ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr));
 	if (ret)
 		return ret;
 
+	buf = kzalloc(sz, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
 	/* Txpower propagation path: TMAC -> TXV -> BBP */
 	len += scnprintf(buf + len, sz - len,
 			 "\nPhy%d Tx power table (channel %d)\n",
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] wifi: mt76: mt7915: fix memory leak in mt7915_rate_txpower_get
  2023-01-03 10:15 [PATCH] wifi: mt76: mt7915: fix memory leak in mt7915_rate_txpower_get Lorenzo Bianconi
@ 2023-01-16 12:16 ` Lorenzo Bianconi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2023-01-16 12:16 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: nbd, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]

> Fix possible memory leak in mt7915_rate_txpower_get routine if
> mt7915_mcu_get_txpower_sku() fails.
> 
> Fixes: e3296759f347 ("wifi: mt76: mt7915: enable per bandwidth power limit support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> index fb46c2c1784f..4730508652af 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> @@ -990,14 +990,14 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
>  	char *buf;
>  	u32 reg;
>  
> -	buf = kzalloc(sz, GFP_KERNEL);
> -	if (!buf)
> -		return -ENOMEM;
> -
>  	ret = mt7915_mcu_get_txpower_sku(phy, txpwr, sizeof(txpwr));
>  	if (ret)
>  		return ret;
>  
> +	buf = kzalloc(sz, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
>  	/* Txpower propagation path: TMAC -> TXV -> BBP */
>  	len += scnprintf(buf + len, sz - len,
>  			 "\nPhy%d Tx power table (channel %d)\n",
> -- 
> 2.39.0
> 

Felix,

It seems there is already a fix for it in your tree so we can drop this patch.

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-16 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-03 10:15 [PATCH] wifi: mt76: mt7915: fix memory leak in mt7915_rate_txpower_get Lorenzo Bianconi
2023-01-16 12:16 ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox