mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] wifi: brcmfmac: Fix potential use-after-free on monitor registration failure
@ 2026-11-16 14:13 Guangshuo Li
  2026-11-24 20:13 ` Arend van Spriel
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-16 14:13 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linux-wireless, brcm80211, brcm80211-dev-list.pdl, linux-kernel

A failed netdevice registration can invoke priv_destructor while
cfg80211_register_netdevice() still needs the wireless_dev embedded in
the vif. The caller also frees the vif on this error path.

Install the destructor only after registration succeeds, as done for
regular interfaces, and leave failed registration cleanup to the caller.

This issue was found by our static analysis tool under development.
Fixes: 20f2c5fa3af0 ("brcmfmac: add initial support for monitor mode")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 46714d871260..aebc8f7b2a41 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -933,7 +933,6 @@ static struct wireless_dev *brcmf_mon_add_vif(struct wiphy *wiphy,
 	ndev->type = ARPHRD_IEEE80211_RADIOTAP;
 	ndev->ieee80211_ptr = &vif->wdev;
 	ndev->needs_free_netdev = true;
-	ndev->priv_destructor = brcmf_cfg80211_free_vif;
 	SET_NETDEV_DEV(ndev, wiphy_dev(cfg->wiphy));
 
 	ifp = netdev_priv(ndev);
@@ -951,6 +950,7 @@ static struct wireless_dev *brcmf_mon_add_vif(struct wiphy *wiphy,
 		goto err_free_vif;
 	}
 
+	ndev->priv_destructor = brcmf_cfg80211_free_vif;
 	cfg->pub->mon_if = ifp;
 
 	return &vif->wdev;

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 14:13 [PATCH] wifi: brcmfmac: Fix potential use-after-free on monitor registration failure Guangshuo Li
2026-11-24 20:13 ` Arend van Spriel

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®