From e8662e9d44ef38a59c79c16eb73484f7d9b09132 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 3 Jun 2021 00:11:18 +0300 Subject: [PATCH] Use a helper function to remove struct wpa_bss_tmp_disallowed entries It is safer to remove and free these entries with a shared helper function to avoid issues with potentially forgetting to unregister or free something if this structure is extended in the future. Signed-off-by: Jouni Malinen --- wpa_supplicant/wpa_supplicant.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 43e8e9a19..0d9b9caa5 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -461,16 +461,22 @@ void free_hw_features(struct wpa_supplicant *wpa_s) } +static void remove_bss_tmp_disallowed_entry(struct wpa_supplicant *wpa_s, + struct wpa_bss_tmp_disallowed *bss) +{ + eloop_cancel_timeout(wpa_bss_tmp_disallow_timeout, wpa_s, bss); + dl_list_del(&bss->list); + os_free(bss); +} + + void free_bss_tmp_disallowed(struct wpa_supplicant *wpa_s) { struct wpa_bss_tmp_disallowed *bss, *prev; dl_list_for_each_safe(bss, prev, &wpa_s->bss_tmp_disallowed, - struct wpa_bss_tmp_disallowed, list) { - eloop_cancel_timeout(wpa_bss_tmp_disallow_timeout, wpa_s, bss); - dl_list_del(&bss->list); - os_free(bss); - } + struct wpa_bss_tmp_disallowed, list) + remove_bss_tmp_disallowed_entry(wpa_s, bss); } @@ -8176,8 +8182,7 @@ static void wpa_bss_tmp_disallow_timeout(void *eloop_ctx, void *timeout_ctx) dl_list_for_each(tmp, &wpa_s->bss_tmp_disallowed, struct wpa_bss_tmp_disallowed, list) { if (bss == tmp) { - dl_list_del(&tmp->list); - os_free(tmp); + remove_bss_tmp_disallowed_entry(wpa_s, tmp); wpa_set_driver_tmp_disallow_list(wpa_s); break; } @@ -8231,10 +8236,7 @@ int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s, if (disallowed->rssi_threshold != 0 && bss->level > disallowed->rssi_threshold) { - eloop_cancel_timeout(wpa_bss_tmp_disallow_timeout, - wpa_s, disallowed); - dl_list_del(&disallowed->list); - os_free(disallowed); + remove_bss_tmp_disallowed_entry(wpa_s, disallowed); wpa_set_driver_tmp_disallow_list(wpa_s); return 0; }