[PATCH 2/2] wifi: nxpwifi: handle authentication frame allocation failures
From: Linmao Li
Date: Thu Aug 20 2026 - 04:17:23 EST
nxpwifi_cfg80211_authenticate() allocates the buffer it builds the
management frame in and never checks the result:
mgmt = kzalloc(frame_len, GFP_KERNEL);
skb = dev_alloc_skb(...);
if (!skb) {
...
return -ENOMEM;
}
...
memcpy(mgmt->da, req->bss->bssid, ETH_ALEN);
On allocation failure the memcpy() a dozen lines later dereferences NULL.
The same sequence leaks mgmt when dev_alloc_skb() fails: that path
returns without freeing it, while the success path drops it after
nxpwifi_form_mgmt_frame().
Bail out when the allocation fails, and free it before returning on the
skb error path.
Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Signed-off-by: Linmao Li <lilinmao@xxxxxxxxxx>
---
drivers/net/wireless/nxp/nxpwifi/cfg80211.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/nxp/nxpwifi/cfg80211.c b/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
index 1f46e4f0157e7..fe9d1b14ddd3e 100644
--- a/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
+++ b/drivers/net/wireless/nxp/nxpwifi/cfg80211.c
@@ -3414,6 +3414,8 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy,
pkt_len = frame_len + ETH_ALEN;
mgmt = kzalloc(frame_len, GFP_KERNEL);
+ if (!mgmt)
+ return -ENOMEM;
skb = dev_alloc_skb(NXPWIFI_MIN_DATA_HEADER_LEN +
NXPWIFI_MGMT_FRAME_HEADER_SIZE +
@@ -3421,6 +3423,7 @@ nxpwifi_cfg80211_authenticate(struct wiphy *wiphy,
if (!skb) {
nxpwifi_dbg(adapter, ERROR,
"allocate skb failed for management frame\n");
+ kfree(mgmt);
return -ENOMEM;
}
--
2.25.1