@@ -133,15 +133,15 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
133
133
ret = create_iov_list (origin_addr , origin_count , origin_dt ,
134
134
& origin_ucx_iov , & origin_ucx_iov_count );
135
135
if (ret != OMPI_SUCCESS ) {
136
- return ret ;
136
+ goto cleanup ;
137
137
}
138
138
}
139
139
140
140
if (!is_target_contig ) {
141
141
ret = create_iov_list (NULL , target_count , target_dt ,
142
142
& target_ucx_iov , & target_ucx_iov_count );
143
143
if (ret != OMPI_SUCCESS ) {
144
- return ret ;
144
+ goto cleanup ;
145
145
}
146
146
}
147
147
@@ -161,7 +161,8 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
161
161
remote_addr + (uint64_t )(target_ucx_iov [target_ucx_iov_idx ].addr ));
162
162
if (OPAL_SUCCESS != status ) {
163
163
OSC_UCX_VERBOSE (1 , "opal_common_ucx_mem_putget failed: %d" , status );
164
- return OMPI_ERROR ;
164
+ ret = OMPI_ERROR ;
165
+ goto cleanup ;
165
166
}
166
167
167
168
origin_ucx_iov [origin_ucx_iov_idx ].addr = (void * )((intptr_t )origin_ucx_iov [origin_ucx_iov_idx ].addr + curr_len );
@@ -195,7 +196,8 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
195
196
remote_addr + target_lb + prev_len );
196
197
if (OPAL_SUCCESS != status ) {
197
198
OSC_UCX_VERBOSE (1 , "opal_common_ucx_mem_putget failed: %d" , status );
198
- return OMPI_ERROR ;
199
+ ret = OMPI_ERROR ;
200
+ goto cleanup ;
199
201
}
200
202
201
203
prev_len += origin_ucx_iov [origin_ucx_iov_idx ].len ;
@@ -217,14 +219,17 @@ static inline int ddt_put_get(ompi_osc_ucx_module_t *module,
217
219
remote_addr + (uint64_t )(target_ucx_iov [target_ucx_iov_idx ].addr ));
218
220
if (OPAL_SUCCESS != status ) {
219
221
OSC_UCX_VERBOSE (1 , "opal_common_ucx_mem_putget failed: %d" , status );
220
- return OMPI_ERROR ;
222
+ ret = OMPI_ERROR ;
223
+ goto cleanup ;
221
224
}
222
225
223
226
prev_len += target_ucx_iov [target_ucx_iov_idx ].len ;
224
227
target_ucx_iov_idx ++ ;
225
228
}
226
229
}
227
230
231
+ cleanup :
232
+
228
233
if (origin_ucx_iov != NULL ) {
229
234
free (origin_ucx_iov );
230
235
}
@@ -291,12 +296,14 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
291
296
len , remote_state_addr );
292
297
if (OPAL_SUCCESS != ret ) {
293
298
OSC_UCX_VERBOSE (1 , "opal_common_ucx_mem_putget failed: %d" , ret );
294
- return OMPI_ERROR ;
299
+ ret = OMPI_ERROR ;
300
+ goto cleanup ;
295
301
}
296
302
297
303
ret = opal_common_ucx_wpmem_flush (module -> state_mem , OPAL_COMMON_UCX_SCOPE_EP , target );
298
- if (ret != OMPI_SUCCESS ) {
299
- return ret ;
304
+ if (ret != OPAL_SUCCESS ) {
305
+ ret = OMPI_ERROR ;
306
+ goto cleanup ;
300
307
}
301
308
302
309
memcpy (& win_count , temp_buf , sizeof (uint64_t ));
@@ -318,6 +325,7 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
318
325
temp_dynamic_wins [contain ].mem_addr , OMPI_OSC_UCX_MEM_ADDR_MAX_LEN );
319
326
module -> local_dynamic_win_info [contain ].mem -> mem_displs [target ] = target * OMPI_OSC_UCX_MEM_ADDR_MAX_LEN ;
320
327
328
+ cleanup :
321
329
free (temp_buf );
322
330
323
331
return ret ;
@@ -486,11 +494,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
486
494
ret = ompi_osc_ucx_get (temp_addr , (int )temp_count , temp_dt ,
487
495
target , target_disp , target_count , target_dt , win );
488
496
if (ret != OMPI_SUCCESS ) {
497
+ free (temp_addr );
489
498
return ret ;
490
499
}
491
500
492
501
ret = opal_common_ucx_wpmem_flush (module -> mem , OPAL_COMMON_UCX_SCOPE_EP , target );
493
502
if (ret != OMPI_SUCCESS ) {
503
+ free (temp_addr );
494
504
return ret ;
495
505
}
496
506
@@ -504,6 +514,7 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
504
514
ret = create_iov_list (origin_addr , origin_count , origin_dt ,
505
515
& origin_ucx_iov , & origin_ucx_iov_count );
506
516
if (ret != OMPI_SUCCESS ) {
517
+ free (temp_addr );
507
518
return ret ;
508
519
}
509
520
@@ -541,11 +552,13 @@ int ompi_osc_ucx_accumulate(const void *origin_addr, int origin_count,
541
552
ret = ompi_osc_ucx_put (temp_addr , (int )temp_count , temp_dt , target , target_disp ,
542
553
target_count , target_dt , win );
543
554
if (ret != OMPI_SUCCESS ) {
555
+ free (temp_addr );
544
556
return ret ;
545
557
}
546
558
547
559
ret = opal_common_ucx_wpmem_flush (module -> mem , OPAL_COMMON_UCX_SCOPE_EP , target );
548
560
if (ret != OMPI_SUCCESS ) {
561
+ free (temp_addr );
549
562
return ret ;
550
563
}
551
564
0 commit comments