Share a common error path for SET_NEIGHBOR control interface command

Instead of constructing a custom error handler freeing the same set of
allocated memory areas on various error cases, share the success path
freeing implementation for the error cases as well.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2021-11-08 23:42:02 +02:00 committed by Jouni Malinen
parent 1b8eb39757
commit b389d88a78

View file

@ -3193,7 +3193,7 @@ static int hostapd_ctrl_iface_set_neighbor(struct hostapd_data *hapd, char *buf)
int stationary = 0; int stationary = 0;
int bss_parameters = 0; int bss_parameters = 0;
char *tmp; char *tmp;
int ret; int ret = -1;
if (!(hapd->conf->radio_measurements[0] & if (!(hapd->conf->radio_measurements[0] &
WLAN_RRM_CAPS_NEIGHBOR_REPORT)) { WLAN_RRM_CAPS_NEIGHBOR_REPORT)) {
@ -3247,8 +3247,7 @@ static int hostapd_ctrl_iface_set_neighbor(struct hostapd_data *hapd, char *buf)
if (!lci) { if (!lci) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"CTRL: SET_NEIGHBOR: Bad LCI subelement"); "CTRL: SET_NEIGHBOR: Bad LCI subelement");
wpabuf_free(nr); goto fail;
return -1;
} }
} }
@ -3264,9 +3263,7 @@ static int hostapd_ctrl_iface_set_neighbor(struct hostapd_data *hapd, char *buf)
if (!civic) { if (!civic) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"CTRL: SET_NEIGHBOR: Bad civic subelement"); "CTRL: SET_NEIGHBOR: Bad civic subelement");
wpabuf_free(nr); goto fail;
wpabuf_free(lci);
return -1;
} }
} }
@ -3282,10 +3279,7 @@ static int hostapd_ctrl_iface_set_neighbor(struct hostapd_data *hapd, char *buf)
if (bss_parameters < 0 || bss_parameters > 0xff) { if (bss_parameters < 0 || bss_parameters > 0xff) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"CTRL: SET_NEIGHBOR: Bad bss_parameters subelement"); "CTRL: SET_NEIGHBOR: Bad bss_parameters subelement");
wpabuf_free(nr); goto fail;
wpabuf_free(lci);
wpabuf_free(civic);
return -1;
} }
} }
@ -3293,6 +3287,7 @@ set:
ret = hostapd_neighbor_set(hapd, bssid, &ssid, nr, lci, civic, ret = hostapd_neighbor_set(hapd, bssid, &ssid, nr, lci, civic,
stationary, bss_parameters); stationary, bss_parameters);
fail:
wpabuf_free(nr); wpabuf_free(nr);
wpabuf_free(lci); wpabuf_free(lci);
wpabuf_free(civic); wpabuf_free(civic);