From edf7294c06188982b98cfcd4f86b8ab45f9eee4d Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 19 May 2021 15:48:51 -0500 Subject: [PATCH] ap: Do not leak ap->server ap_reset() seems to be called whenever the AP is stopped or removed due to interface shutdown. For some reason ap_reset did not remove the DHCP server object, resulting in leaks: ==211== at 0x483879F: malloc (vg_replace_malloc.c:307) ==211== by 0x46B5AD: l_malloc (util.c:62) ==211== by 0x49B0E2: l_dhcp_server_new (dhcp-server.c:715) ==211== by 0x433AA3: ap_setup_dhcp (ap.c:2615) ==211== by 0x433AA3: ap_load_dhcp (ap.c:2645) ==211== by 0x433AA3: ap_load_config (ap.c:2753) ==211== by 0x433AA3: ap_start (ap.c:2885) ==211== by 0x434A96: ap_dbus_start_profile (ap.c:3329) ==211== by 0x482DA9: _dbus_object_tree_dispatch (dbus-service.c:1815) ==211== by 0x47A4D9: message_read_handler (dbus.c:285) ==211== by 0x4720EB: io_callback (io.c:120) ==211== by 0x47130C: l_main_iterate (main.c:478) ==211== by 0x4713DB: l_main_run (main.c:525) ==211== by 0x4713DB: l_main_run (main.c:507) ==211== by 0x4715EB: l_main_run_with_signal (main.c:647) ==211== by 0x403EE1: main (main.c:550) --- src/ap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ap.c b/src/ap.c index 7eac07d7..fff7c664 100644 --- a/src/ap.c +++ b/src/ap.c @@ -335,8 +335,10 @@ static void ap_reset(struct ap_state *ap) l_free(ap->own_ip); } - if (ap->server) - l_dhcp_server_stop(ap->server); + if (ap->server) { + l_dhcp_server_destroy(ap->server); + ap->server = NULL; + } } static void ap_del_station(struct sta_state *sta, uint16_t reason, @@ -3072,8 +3074,6 @@ void ap_free(struct ap_state *ap) { ap_reset(ap); l_genl_family_free(ap->nl80211); - if (ap->server) - l_dhcp_server_destroy(ap->server); l_free(ap); }