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)
This commit is contained in:
Denis Kenzior 2021-05-19 15:48:51 -05:00
parent 23451be606
commit edf7294c06
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}