wifi: mt76: mt7915: fix ext PHY use-after-free on register error path

After mt7915_register_ext_phy() succeeded, a failure of the main PHY
mt7915_init_debugfs() or mt7915_coredump_register() unwound through
free_phy2, which called ieee80211_free_hw() on the ext PHY hw while it
was still registered with mac80211, since mt76_unregister_device() only
unregisters the main hw. Unregister the ext PHY (thermal + phy + hw)
first and skip the redundant free.

Fixes: 7b8e1ae886e4 ("mt76: mt7915: rework hardware/phy initialization")
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2026-08-26 12:24:29 +02:00
parent 69f26dbae7
commit dabd945ef4
+7 -2
View File
@@ -1335,14 +1335,19 @@ int mt7915_register_device(struct mt7915_dev *dev)
ret = mt7915_init_debugfs(&dev->phy);
if (ret)
goto unreg_thermal;
goto unreg_ext_phy;
ret = mt7915_coredump_register(dev);
if (ret)
goto unreg_thermal;
goto unreg_ext_phy;
return 0;
unreg_ext_phy:
if (phy2) {
mt7915_unregister_ext_phy(dev);
phy2 = NULL;
}
unreg_thermal:
mt7915_unregister_thermal(&dev->phy);
unreg_dev: