mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiale Yao <yaojiale02@163.com>
To: Bob Copeland <me@bobcopeland.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	Kalle Valo <kalle.valo@nokia.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiale Yao <yaojiale02@163.com>
Subject: [PATCH 1/2] wifi: wl1251: unwind failed interface additions
Date: Mon, 19 Oct 2026 09:32:23 +0800	[thread overview]
Message-ID: <20261019013224.1489500-2-yaojiale02@163.com> (raw)
In-Reply-To: <20261019013224.1489500-1-yaojiale02@163.com>

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@163.com>
---
 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


  reply	other threads:[~2026-10-19  1:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  1:32 [PATCH 0/2] wifi: ti: " Jiale Yao
2026-10-19  1:32 ` Jiale Yao [this message]
2026-10-19  1:32 ` [PATCH 2/2] wifi: wlcore: " Jiale Yao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019013224.1489500-2-yaojiale02@163.com \
    --to=yaojiale02@163.com \
    --cc=kalle.valo@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=me@bobcopeland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®