Skip to content

Commit 771f9c0

Browse files
committed
coll/tuned: Add NULL check to prevent segfault
Signed-off-by: William Zhang <wilzhang@amazon.com> cr https://code.amazon.com/reviews/CR-23837553
1 parent 5064040 commit 771f9c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ompi/mca/coll/tuned/coll_tuned_dynamic_file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
142142
OPAL_OUTPUT((ompi_coll_tuned_stream, "Read communicator count %d for dynamic rule for collective ID %d\n", NCS, CI));
143143
alg_p->n_com_sizes = NCS;
144144
alg_p->com_rules = ompi_coll_tuned_mk_com_rules (NCS, CI);
145+
if (NULL == alg_p->com_rules) {
146+
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate com rules for file [%s]\n", fname));
147+
goto on_file_error;
148+
}
145149

146150
for (ncs=0;ncs<NCS;ncs++) { /* for each comm size */
147151

@@ -164,6 +168,10 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
164168
NMS, CI, CS));
165169
com_p->n_msg_sizes = NMS;
166170
com_p->msg_rules = ompi_coll_tuned_mk_msg_rules (NMS, CI, ncs, CS);
171+
if (NULL == com_p->msg_rules) {
172+
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate msg rules for file [%s]\n", fname));
173+
goto on_file_error;
174+
}
167175

168176
msg_p = com_p->msg_rules;
169177

0 commit comments

Comments
 (0)