static void __netconfig_agent_clear_fields(void)
{
- g_byte_array_free(agent.ssid, TRUE);
+ if (agent.ssid)
+ g_byte_array_free(agent.ssid, TRUE);
g_free(agent.name);
g_free(agent.identity);
g_free(agent.passphrase);
reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
service, CONNMAN_SERVICE_INTERFACE, "Connect",
NULL, __netconfig_wifi_connect_reply);
- if (reply == TRUE) {
- g_dbus_method_invocation_return_value(context, NULL);
- } else {
+ if (reply != TRUE) {
+ ERR("Fail to connect Wi-Fi");
+ __netconfig_agent_clear_fields();
error = g_error_new(G_DBUS_ERROR,
G_DBUS_ERROR_AUTH_FAILED,
CONNMAN_ERROR_INTERFACE ".InvalidArguments");
g_dbus_method_invocation_return_gerror(context, error);
g_clear_error(&error);
+ return reply;
}
} else {
error = g_error_new(G_DBUS_ERROR,
g_dbus_method_invocation_return_gerror(context, error);
g_clear_error(&error);
+ return reply;
}
- if (reply != TRUE) {
- ERR("Fail to connect Wi-Fi");
-
- __netconfig_agent_clear_fields();
- }
g_variant_iter_free(iter);
net_connman_agent_complete_set_field(connman_agent, context);
}
__netconfig_agent_clear_fields();
- g_variant_unref(out_table);
return updated;
}