From cd855104f24d06707373b70cd6fa73e645d8e4ce Mon Sep 17 00:00:00 2001 From: Gaetan Perrot Date: Tue, 8 Jul 2025 16:27:20 +0900 Subject: [PATCH] modules: hostap: hapd_events: Fix possible null deference Move usage of ap_ctx pointers after null checks to prevent potential crashes. Signed-off-by: Gaetan Perrot --- modules/hostap/src/hapd_events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/hostap/src/hapd_events.c b/modules/hostap/src/hapd_events.c index 2d297b71aff..deb4c1705de 100644 --- a/modules/hostap/src/hapd_events.c +++ b/modules/hostap/src/hapd_events.c @@ -69,13 +69,15 @@ int hostapd_send_wifi_mgmt_ap_sta_event(struct hostapd_iface *ap_ctx, void *data) { struct sta_info *sta = data; - char *ifname = ap_ctx->bss[0]->conf->iface; + char *ifname; struct wifi_ap_sta_info sta_info = { 0 }; if (!ap_ctx || !sta) { return -EINVAL; } + ifname = ap_ctx->bss[0]->conf->iface; + memcpy(sta_info.mac, sta->addr, sizeof(sta_info.mac)); if (event == NET_EVENT_WIFI_CMD_AP_STA_CONNECTED) {