From 36e885ca1f4115203e05e2886ae32563247b3b97 Mon Sep 17 00:00:00 2001
From: Mattias Walström <lazzer@gmail.com>
Date: Mon, 19 Jan 2026 13:06:53 +0100
Subject: [PATCH 30/33] wifi: brcmfmac: check connection state before querying
 station info
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires

In station mode, brcmf_cfg80211_get_station() queries the firmware for
station info even when not connected to an AP. This results in error
-52 (EBADE) from firmware and noisy log messages:

  brcmf_cfg80211_get_station: GET STA INFO failed, -52

Add a check for BRCMF_VIF_STATUS_CONNECTED before querying station
info in station mode. AP mode is not affected as it needs to query
info about connected clients regardless of its own connection state.

Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index bcd8a4724625..f06658d4299b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3303,6 +3303,11 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
 	if (brcmf_is_ibssmode(ifp->vif))
 		return brcmf_cfg80211_get_station_ibss(ifp, sinfo);
 
+	/* In station mode, we can only get station info when connected */
+	if (!brcmf_is_apmode(ifp->vif) &&
+	    !test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state))
+		return -ENOENT;
+
 	memset(&sta_info_le, 0, sizeof(sta_info_le));
 	memcpy(&sta_info_le, mac, ETH_ALEN);
 	err = brcmf_fil_iovar_data_get(ifp, "tdls_sta_info",
