From: Hannu Mallat Date: Mon, 12 May 2014 11:33:12 +0000 (+0300) Subject: dbus: Reorder deauthentication and cleanup calls when removing a network X-Git-Tag: hostap_2_2~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=316f92cd332668b884da11f909396bcc4effdd92;p=thirdparty%2Fhostap.git dbus: Reorder deauthentication and cleanup calls when removing a network Valgrind indicates reference to already freed memory if function wpa_config_remove_network() is called prior to calling wpa_supplicant_deauthenticate(), and this can lead to a crash. Inverting the call order fixes the problem. Signed-off-by: Hannu Mallat --- diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 33a1ba94d..bd38d65e0 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -1583,16 +1583,6 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message, wpas_notify_network_removed(wpa_s, ssid); - if (wpa_config_remove_network(wpa_s->conf, id) < 0) { - wpa_printf(MSG_ERROR, - "wpas_dbus_handler_remove_network[dbus]: " - "error occurred when removing network %d", id); - reply = wpas_dbus_error_unknown_error( - message, "error removing the specified network on " - "this interface."); - goto out; - } - if (ssid == wpa_s->current_ssid) wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); @@ -1603,6 +1593,15 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message, wpa_supplicant_req_scan(wpa_s, 0, 0); } + if (wpa_config_remove_network(wpa_s->conf, id) < 0) { + wpa_printf(MSG_ERROR, + "wpas_dbus_handler_remove_network[dbus]: " + "error occurred when removing network %d", id); + reply = wpas_dbus_error_unknown_error( + message, "error removing the specified network on " + "this interface."); + goto out; + } out: os_free(iface);