Skip to content

Commit

Permalink
modules: hostap: Fix memory leak
Browse files Browse the repository at this point in the history
The control interface is initialized on every interface add but only
de-initialized on WPA supplicant termination. This leaks all cleanups in
the control interface dei-init.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 authored and de-nordic committed Sep 15, 2023
1 parent cedccb7 commit 8e57854
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ static int z_wpas_remove_interface(const char *ifname)
goto err;
}

z_wpa_ctrl_deinit(wpa_s);

ret = z_wpa_cli_global_cmd_v("interface_remove %s", ifname);
if (ret) {
wpa_printf(MSG_ERROR, "Failed to remove interface: %s", ifname);
Expand All @@ -277,6 +279,7 @@ static int z_wpas_remove_interface(const char *ifname)
goto err;
}


if (z_wpas_get_iface_count() == 0) {
generate_supp_state_event(ifname, NET_EVENT_WPA_SUPP_CMD_NOT_READY, 0);
}
Expand Down Expand Up @@ -518,7 +521,6 @@ static void z_wpas_start(void)
generate_supp_state_event(DEFAULT_IFACE_NAME, NET_EVENT_WPA_SUPP_CMD_NOT_READY, 0);
eloop_unregister_read_sock(z_wpas_event_sockpair[0]);

z_wpa_ctrl_deinit();
z_global_wpa_ctrl_deinit();
wpa_supplicant_deinit(global);

Expand Down

0 comments on commit 8e57854

Please sign in to comment.