[PATCH 1/2] wifi: wl1251: unwind failed interface additions

From: Jiale Yao

Date: Sun Oct 18 2026 - 21:36:08 EST


wl1251 stores the vif and updates interface state before validating the
type and programming a changed station address. Failures leave the vif
installed even though mac80211 will not invoke remove_interface.

Publish the vif only after all fallible setup succeeds and restore the
previous BSS and address state on failure.

Fixes: 2f01a1f58889 ("wl12xx: add driver")
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/net/wireless/ti/wl1251/main.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c
index 0f3f22e729ce..306dd6379931 100644
--- a/drivers/net/wireless/ti/wl1251/main.c
+++ b/drivers/net/wireless/ti/wl1251/main.c
@@ -481,6 +481,8 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
struct wl1251 *wl = hw->priv;
+ u8 old_mac_addr[ETH_ALEN];
+ u8 old_bss_type;
int ret = 0;

vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
@@ -496,7 +498,8 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
goto out;
}

- wl->vif = vif;
+ memcpy(old_mac_addr, wl->mac_addr, ETH_ALEN);
+ old_bss_type = wl->bss_type;

switch (vif->type) {
case NL80211_IFTYPE_STATION:
@@ -507,7 +510,7 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
break;
default:
ret = -EOPNOTSUPP;
- goto out;
+ goto restore;
}

if (!ether_addr_equal_unaligned(wl->mac_addr, vif->addr)) {
@@ -515,9 +518,17 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
ret = wl1251_acx_station_id(wl);
if (ret < 0)
- goto out;
+ goto restore;
}

+ wl->vif = vif;
+ goto out;
+
+restore:
+ wl->bss_type = old_bss_type;
+ memcpy(wl->mac_addr, old_mac_addr, ETH_ALEN);
+ SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
+
out:
mutex_unlock(&wl->mutex);
return ret;
--
2.34.1