[PATCH] wifi: brcmfmac: avoid WARN on unexpected PNO result metadata

From: YuanZhe Liu

Date: Sat Dec 05 2026 - 11:49:50 EST


brcmf_notify_sched_scan_results() and brcmf_wowl_nd_results() parse the
PNO scan results reported by the firmware. Two fields of the result
header are currently validated with WARN_ON(): a status other than
BRCMF_PNO_SCAN_COMPLETE, and a result format version other than 1 or 2.
Both are device-provided values, so a malformed or newer firmware event
can trigger the warning and taint the kernel. The unsupported version is
additionally parsed as a version 1 result, which yields a wrong offset to
the network information.

Handle these cases the way other invalid firmware data is handled in this
driver (see brcmf_inform_bss()): report a partial result through the scan
debug channel and reject an unsupported result version with bphy_err()
instead of warning. A version 1 or 2 result is processed as before.

Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>
---
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 21 ++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 62d072b6369e..8d78c2e75da3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -3850,9 +3850,6 @@ brcmf_get_netinfo_array(struct brcmf_pno_scanresults_le *pfn_v1)
struct brcmf_pno_net_info_le *netinfo;

switch (pfn_v1->version) {
- default:
- WARN_ON(1);
- fallthrough;
case cpu_to_le32(1):
netinfo = (struct brcmf_pno_net_info_le *)(pfn_v1 + 1);
break;
@@ -3860,6 +3857,8 @@ brcmf_get_netinfo_array(struct brcmf_pno_scanresults_le *pfn_v1)
pfn_v2 = (struct brcmf_pno_scanresults_v2_le *)pfn_v1;
netinfo = (struct brcmf_pno_net_info_le *)(pfn_v2 + 1);
break;
+ default:
+ return NULL;
}

return netinfo;
@@ -3904,9 +3903,10 @@ brcmf_notify_sched_scan_results(struct brcmf_if *ifp,
status = le32_to_cpu(pfn_result->status);

/* PFN event is limited to fit 512 bytes so we may get
- * multiple NET_FOUND events. For now place a warning here.
+ * multiple NET_FOUND events.
*/
- WARN_ON(status != BRCMF_PNO_SCAN_COMPLETE);
+ if (status != BRCMF_PNO_SCAN_COMPLETE)
+ brcmf_dbg(SCAN, "PNO scan not complete: status %u\n", status);
brcmf_dbg(SCAN, "PFN NET FOUND event. count: %d\n", result_count);
if (!result_count) {
bphy_err(drvr, "FALSE PNO Event. (pfn_count == 0)\n");
@@ -3914,6 +3914,12 @@ brcmf_notify_sched_scan_results(struct brcmf_if *ifp,
}

netinfo_start = brcmf_get_netinfo_array(pfn_result);
+ if (!netinfo_start) {
+ bphy_err(drvr, "PNO result version %u unsupported\n",
+ le32_to_cpu(pfn_result->version));
+ err = -EOPNOTSUPP;
+ goto out_err;
+ }
datalen = e->datalen - ((void *)netinfo_start - (void *)pfn_result);
if (datalen < result_count * sizeof(*netinfo)) {
bphy_err(drvr, "insufficient event data\n");
@@ -4076,6 +4082,11 @@ brcmf_wowl_nd_results(struct brcmf_if *ifp, const struct brcmf_event_msg *e,
}

netinfo = brcmf_get_netinfo_array(pfn_result);
+ if (!netinfo) {
+ bphy_err(drvr, "PNO result version %u unsupported\n",
+ le32_to_cpu(pfn_result->version));
+ return -EOPNOTSUPP;
+ }
if (netinfo->SSID_len > IEEE80211_MAX_SSID_LEN)
netinfo->SSID_len = IEEE80211_MAX_SSID_LEN;
memcpy(cfg->wowl.nd->ssid.ssid, netinfo->SSID, netinfo->SSID_len);
--
2.34.1