[PATCH 1/5] AP: fix memory leaks in SAE offload error cases
Johannes Berg
johannes at sipsolutions.net
Tue Mar 17 06:05:00 PDT 2026
From: Johannes Berg <johannes.berg at intel.com>
If SAE offload configuration fails in ieee802_11_build_ap_params(),
head/tail are leaked. Fix this by using an error label.
Fixes: b089803091cf ("hostapd: Add support for SAE offload for AP interface")
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
src/ap/beacon.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index dd3866460dbb..f16ff1fdcb06 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -2309,9 +2309,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
tailpos = tail = os_malloc(tail_len);
if (head == NULL || tail == NULL) {
wpa_printf(MSG_ERROR, "Failed to set beacon data");
- os_free(head);
- os_free(tail);
- return -1;
+ goto error;
}
tailend = tail + tail_len;
@@ -2389,11 +2387,9 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
if (hapd->iconf->mbssid && hapd->iconf->num_bss > 1) {
if (ieee802_11_build_ap_params_mbssid(hapd, params)) {
- os_free(head);
- os_free(tail);
wpa_printf(MSG_ERROR,
"MBSSID: Failed to set beacon data");
- return -1;
+ goto error;
}
complete = hapd->iconf->mbssid == MBSSID_ENABLED ||
(hapd->iconf->mbssid == ENHANCED_MBSSID_ENABLED &&
@@ -2568,20 +2564,20 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
if (hostapd_sae_pk_in_use(hapd->conf)) {
wpa_printf(MSG_ERROR,
"SAE PK not supported with SAE offload");
- return -1;
+ goto error;
}
if (hostapd_sae_pw_id_in_use(hapd->conf)) {
wpa_printf(MSG_ERROR,
"SAE Password Identifiers not supported with SAE offload");
- return -1;
+ goto error;
}
params->sae_password = sae_get_password(hapd, NULL, NULL, 0,
NULL, NULL, NULL);
if (!params->sae_password) {
wpa_printf(MSG_ERROR, "SAE password not configured for offload");
- return -1;
+ goto error;
}
}
#endif /* CONFIG_SAE */
@@ -2682,6 +2678,13 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
#endif /* CONFIG_IEEE80211BE */
return 0;
+#if defined(CONFIG_SAE) || defined(NEED_AP_MLME)
+error:
+ os_free(head);
+ os_free(tail);
+ os_free(resp);
+ return -1;
+#endif /* CONFIG_SAE || NEED_AP_MLME */
}
--
2.53.0
More information about the Hostap
mailing list