Skip to contentSkip to conversation

wifi: mt76: fix potential memory leak in mt76_wmac_probe()

PATCH In review Abdun Nihaal 2 participants 2 messages Jul 9, 2025 – Jul 10, 2025

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

PATCH 1/1 wifi: mt76: fix potential memory leak in mt76_wmac_probe()

In mt76_wmac_probe(), when the mt76_alloc_device() call succeeds, memory is allocated for both struct ieee80211_hw and a workqueue. However, on the error path, the workqueue is not freed. Fix that by calling mt76_free_device() on the error path.

Fixes c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")

---
This patch is compile tested only. Not tested on real hardware.

 drivers/net/wireless/mediatek/mt76/mt7603/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7603/soc.c +1 -1
index 08590aa68356..1dd372372048 100644
@@ -48,7 +48,7 @@ mt76_wmac_probe(struct platform_device *pdev)
 
 	return 0;
 error:
-	ieee80211_free_hw(mt76_hw(dev));
+	mt76_free_device(mdev);
 	return ret;
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Abdun Nihaal

In mt76_wmac_probe(), when the mt76_alloc_device() call succeeds, memory is allocated for both struct ieee80211_hw and a workqueue. However, on the error path, the workqueue is not freed. Fix that by calling mt76_free_device() on the error path.

Fixes c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")

I am not sure, why I am CCed, but makes sense anyway (free the one obtained by alloc_ordered_workqueue() in mt76_alloc_device()):

Signature · 2 lines
js
suse labs