Skip to content

Commit 5e45a9d

Browse files
authored
Merge pull request #12615 from ggouaillardet/topic/op_memory_leaks
op: plug memory leaks
2 parents 9f58fd2 + 0517663 commit 5e45a9d

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

ompi/mca/op/aarch64/op_aarch64_component.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* reserved.
55
* Copyright (c) 2019 ARM Ltd. All rights reserved.
66
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
7+
* Copyright (c) 2024 Research Organization for Information Science
8+
* and Technology (RIST). All rights reserved.
79
*
810
* $COPYRIGHT$
911
*
@@ -165,13 +167,16 @@ ompi_op_aarch64_3buff_functions_sve[OMPI_OP_BASE_FORTRAN_OP_MAX][OMPI_OP_BASE_TY
165167
static struct ompi_op_base_module_1_0_0_t *
166168
mca_op_aarch64_component_op_query(struct ompi_op_t *op, int *priority)
167169
{
168-
ompi_op_base_module_t *module = OBJ_NEW(ompi_op_base_module_t);
169170
/* Sanity check -- although the framework should never invoke the
170171
_component_op_query() on non-intrinsic MPI_Op's, we'll put a
171172
check here just to be sure. */
172173
if (0 == (OMPI_OP_FLAGS_INTRINSIC & op->o_flags)) {
173174
return NULL;
174175
}
176+
ompi_op_base_module_t *module = OBJ_NEW(ompi_op_base_module_t);
177+
if (NULL == module) {
178+
return NULL;
179+
}
175180

176181
switch (op->o_f_to_c_index) {
177182
case OMPI_OP_BASE_FORTRAN_MAX:
@@ -200,30 +205,30 @@ static struct ompi_op_base_module_1_0_0_t *
200205
}
201206
}
202207
#endif /* defined(OMPI_MCA_OP_HAVE_NEON) */
203-
if( NULL != module->opm_fns[i] ) {
204-
OBJ_RETAIN(module);
205-
}
206-
if( NULL != module->opm_3buff_fns[i] ) {
207-
OBJ_RETAIN(module);
208-
}
209208
}
210209
break;
211210
case OMPI_OP_BASE_FORTRAN_LAND:
211+
OBJ_RELEASE(module);
212212
module = NULL;
213213
break;
214214
case OMPI_OP_BASE_FORTRAN_LOR:
215+
OBJ_RELEASE(module);
215216
module = NULL;
216217
break;
217218
case OMPI_OP_BASE_FORTRAN_LXOR:
219+
OBJ_RELEASE(module);
218220
module = NULL;
219221
break;
220222
case OMPI_OP_BASE_FORTRAN_MAXLOC:
223+
OBJ_RELEASE(module);
221224
module = NULL;
222225
break;
223226
case OMPI_OP_BASE_FORTRAN_MINLOC:
227+
OBJ_RELEASE(module);
224228
module= NULL;
225229
break;
226230
default:
231+
OBJ_RELEASE(module);
227232
module= NULL;
228233
}
229234
/* If we got a module from above, we'll return it. Otherwise,

ompi/mca/op/base/op_base_op_select.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* rights reserved.
1515
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1616
* Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
17-
* Copyright (c) 2020 Research Organization for Information Science
17+
* Copyright (c) 2020-2024 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -163,7 +163,7 @@ int ompi_op_base_op_select(ompi_op_t *op)
163163

164164
/* 3-buffer variants */
165165
if (NULL != avail->ao_module->opm_3buff_fns[i]) {
166-
OBJ_RELEASE(op->o_func.intrinsic.modules[i]);
166+
OBJ_RELEASE(op->o_3buff_intrinsic.modules[i]);
167167
op->o_3buff_intrinsic.fns[i] =
168168
avail->ao_module->opm_3buff_fns[i];
169169
op->o_3buff_intrinsic.modules[i] = avail->ao_module;

0 commit comments

Comments
 (0)