Skip to contentSkip to conversation

wifi: mwifiex: fix double free in mwifiex_send_rgpower_table()

PATCH In review Dan Carpenter 3 participants 3 messages Sep 5, 2025 – Sep 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mwifiex: fix double free in mwifiex_send_rgpower_table()

The "hostcmd" is freed using cleanup.h, so calling kfree() will lead to a double free. Delete the kfree().

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
---
 drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_cmd.c +1 -3
index 6d9e2af29a69..91d5098081e8 100644
@@ -1521,10 +1521,8 @@ int mwifiex_send_rgpower_table(struct mwifiex_private *priv, const u8 *data,
 		return -ENOMEM;
 
 	_data = kmemdup(data, size, GFP_KERNEL);
-	if (!_data) {
-		kfree(hostcmd);
+	if (!_data)
 		return -ENOMEM;
-	}
 
 	pos = _data;
 	ptr = hostcmd->cmd;
Signature · 1 line
2.47.2
#2 lore raw
In reply to Dan Carpenter

Hi Dan,

thanks for spotting and fixing the double free error. I converted the code to use the cleanup helper late in the dev process and forgot to remove the call. I sent a patch for the endianness bug as well.

Quoted 15 lines · Dan Carpenter

The "hostcmd" is freed using cleanup.h, so calling kfree() will lead to a double free. Delete the kfree().

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
---
  drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_cmd.c +0 -0
index 6d9e2af29a69..91d5098081e8 100644
@@ -1521,10 +1521,8 @@ int mwifiex_send_rgpower_table(struct mwifiex_private *priv, const u8 *data,
  		return -ENOMEM;

drivers/net/wireless/marvell/mwifiex/sta_cmd.c int mwifiex_send_rgpower_table(struct mwifiex_private *priv, const u8 *data, · line 1528

Quoted 10 lines
drivers/net/wireless/marvell/mwifiex/sta_cmd.c +1 -3
 
  	_data = kmemdup(data, size, GFP_KERNEL);
-	if (!_data) {
-		kfree(hostcmd);
+	if (!_data)
  		return -ENOMEM;
-	}
 
  	pos = _data;
  	ptr = hostcmd->cmd;

Thank you,
Stefan

Signature · 4 lines
Pengutronix e.K.                       | Stefan Kerkmann             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |