@@ -76,6 +76,8 @@ static __TLS os_last_native_error_t TLS_last_native_error;
7676 (UMF_OS_RESULT_ERROR_PURGE_LAZY_FAILED - UMF_OS_RESULT_SUCCESS)
7777#define _UMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED \
7878 (UMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED - UMF_OS_RESULT_SUCCESS)
79+ #define _UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED \
80+ (UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED - UMF_OS_RESULT_SUCCESS)
7981
8082static const char * Native_error_str [] = {
8183 [_UMF_OS_RESULT_SUCCESS ] = "success" ,
@@ -86,6 +88,8 @@ static const char *Native_error_str[] = {
8688 [_UMF_OS_RESULT_ERROR_FREE_FAILED ] = "memory deallocation failed" ,
8789 [_UMF_OS_RESULT_ERROR_PURGE_LAZY_FAILED ] = "lazy purging failed" ,
8890 [_UMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED ] = "force purging failed" ,
91+ [_UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED ] =
92+ "HWLOC topology discovery failed" ,
8993};
9094
9195static void os_store_last_native_error (int32_t native_error , int errno_value ) {
@@ -291,23 +295,24 @@ static umf_result_t os_initialize(void *params, void **provider) {
291295 if (os_provider -> traces ) {
292296 fprintf (stderr , "HWLOC topology init failed\n" );
293297 }
294- umf_ba_free (base_allocator , os_provider );
298+ ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
299+ goto err_free_os_provider ;
295300 }
296301
297302 r = hwloc_topology_load (os_provider -> topo );
298303 if (r ) {
304+ os_store_last_native_error (UMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED ,
305+ 0 );
299306 if (os_provider -> traces ) {
300307 fprintf (stderr , "HWLOC topology discovery failed\n" );
301308 }
302- hwloc_topology_destroy ( os_provider -> topo ) ;
303- umf_ba_free ( base_allocator , os_provider ) ;
309+ ret = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC ;
310+ goto err_destroy_hwloc_topology ;
304311 }
305312
306313 ret = translate_params (in_params , os_provider );
307314 if (ret != UMF_RESULT_SUCCESS ) {
308- hwloc_topology_destroy (os_provider -> topo );
309- umf_ba_free (base_allocator , os_provider );
310- return ret ;
315+ goto err_destroy_hwloc_topology ;
311316 }
312317
313318 if (os_provider -> traces ) {
@@ -324,6 +329,12 @@ static umf_result_t os_initialize(void *params, void **provider) {
324329 * provider = os_provider ;
325330
326331 return UMF_RESULT_SUCCESS ;
332+
333+ err_destroy_hwloc_topology :
334+ hwloc_topology_destroy (os_provider -> topo );
335+ err_free_os_provider :
336+ umf_ba_free (base_allocator , os_provider );
337+ return ret ;
327338}
328339
329340static void os_finalize (void * provider ) {
0 commit comments