if (g_hal_location_funcs)
return 0;
+ g_hal_location_funcs = calloc(1, sizeof(hal_backend_location_funcs));
+ if (!g_hal_location_funcs)
+ return -ENOMEM;
+
ret = hal_common_get_backend(HAL_MODULE_LOCATION, (void **)&g_hal_location_funcs);
if (ret < 0) {
+ free(g_hal_location_funcs);
+ g_hal_location_funcs = NULL;
_E("Failed to get backend\n");
- return -EINVAL;
+ return -ENOTSUP;
}
return 0;
ret = hal_common_put_backend(HAL_MODULE_LOCATION, (void *)g_hal_location_funcs);
if (ret < 0) {
_E("Failed to put backend\n");
- return -EINVAL;
+ return ret;
}
+
+ free(g_hal_location_funcs);
g_hal_location_funcs = NULL;
return 0;