commit f92ce9441efb1f8fd13d8aba57ba81421e824b0c
parent 2acda158ef4ace7958c0f8ccb68bf9f331f5974f
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Wed, 8 Apr 2020 18:44:15 -0700
storage: Refactor dirs creation logic to cleanup on failure
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/storage.c b/src/storage.c
@@ -200,16 +200,24 @@ bool storage_create_dirs(void)
}
storage_path = l_strdup(state_dirs[0]);
- storage_hotspot_path = l_strdup_printf("%s/hotspot/", state_dirs[0]);
l_strv_free(state_dirs);
if (create_dirs(storage_path)) {
l_error("Failed to create %s", storage_path);
+
+ l_free(storage_path);
+
return false;
}
+ storage_hotspot_path = l_strdup_printf("%s/hotspot/", storage_path);
+
if (create_dirs(storage_hotspot_path)) {
l_error("Failed to create %s", storage_hotspot_path);
+
+ l_free(storage_path);
+ l_free(storage_hotspot_path);
+
return false;
}