const char *ident;
char *str, *hex_ssid;
gboolean service_created = FALSE;
+ int err;
/* Strip off "service_" prefix */
ident = group + 8;
ssid = g_try_malloc0(hex_ssid_len / 2);
if (ssid == NULL) {
+ err = -ENOMEM;
g_free(hex_ssid);
- return -ENOMEM;
+ goto err;
}
for (i = 0; i < hex_ssid_len; i += 2) {
ssid_len = strlen(service->name);
ssid = g_try_malloc0(ssid_len);
- if (ssid == NULL)
- return -ENOMEM;
+ if (ssid == NULL) {
+ err = -ENOMEM;
+ goto err;
+ }
memcpy(ssid, service->name, ssid_len);
g_free(service->ssid);
if (is_protected_service(service) == TRUE) {
connman_error("Trying to provision a protected service");
-
- g_free(service->ident);
- g_free(service->type);
- g_free(service->name);
- g_free(service->ssid);
- g_free(service);
-
- return -EACCES;
+ err = -EACCES;
+ goto err;
}
str = g_key_file_get_string(keyfile, group, SERVICE_KEY_EAP, NULL);
connman_info("Adding service configuration %s", service->ident);
return 0;
+
+err:
+ if (service_created == TRUE) {
+ g_free(service->ident);
+ g_free(service->type);
+ g_free(service->name);
+ g_free(service->ssid);
+ g_free(service);
+ }
+
+ return err;
}
static int load_config(struct connman_config *config)