Skip to content

Commit 8ac9bf1

Browse files
authored
Merge pull request #10890 from cniethammer/fix-resource-leak
Fix resource leak reported by coverity scan report CID 1515830
2 parents ea33673 + 03df021 commit 8ac9bf1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (C) 2001-2017 Mellanox Technologies Ltd. ALL RIGHTS RESERVED.
3-
* Copyright (c) 2019-2020 High Performance Computing Center Stuttgart,
3+
* Copyright (c) 2019-2022 High Performance Computing Center Stuttgart,
44
* University of Stuttgart. All rights reserved.
55
* Copyright (c) 2021 IBM Corporation. All rights reserved.
66
* $COPYRIGHT$
@@ -255,7 +255,7 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
255255
int target, bool lock_required) {
256256
uint64_t remote_state_addr = (module->state_addrs)[target] + OSC_UCX_STATE_DYNAMIC_WIN_CNT_OFFSET;
257257
size_t remote_state_len = sizeof(uint64_t) + sizeof(ompi_osc_dynamic_win_info_t) * OMPI_OSC_UCX_ATTACH_MAX;
258-
char *temp_buf = calloc(remote_state_len, 1);
258+
char *temp_buf;
259259
ompi_osc_dynamic_win_info_t *temp_dynamic_wins;
260260
int contain = 0;
261261
uint64_t win_count;
@@ -268,11 +268,12 @@ static inline int get_dynamic_win_info(uint64_t remote_addr, ompi_osc_ucx_module
268268
* Therefore, force lock is needed. Remote process protects its window
269269
* attach/detach operations with an acc-lock */
270270
ret = ompi_osc_state_lock(module, target, &lock_acquired, true);
271-
if (ret != OMPI_SUCCESS) {
271+
if (OMPI_SUCCESS != ret) {
272272
return ret;
273273
}
274274
}
275275

276+
temp_buf = calloc(remote_state_len, 1);
276277
ret = opal_common_ucx_wpmem_putget(module->state_mem, OPAL_COMMON_UCX_GET, target,
277278
(void *)((intptr_t)temp_buf),
278279
remote_state_len, remote_state_addr);

0 commit comments

Comments
 (0)