From 771f9c011d2a4daf78a4b26f88c971b3868fe132 Mon Sep 17 00:00:00 2001 From: William Zhang Date: Tue, 14 Apr 2020 23:02:41 +0000 Subject: [PATCH] coll/tuned: Add NULL check to prevent segfault Signed-off-by: William Zhang cr https://code.amazon.com/reviews/CR-23837553 --- ompi/mca/coll/tuned/coll_tuned_dynamic_file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c b/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c index 4ab319b85e..7ba85078fd 100644 --- a/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c +++ b/ompi/mca/coll/tuned/coll_tuned_dynamic_file.c @@ -142,6 +142,10 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** OPAL_OUTPUT((ompi_coll_tuned_stream, "Read communicator count %d for dynamic rule for collective ID %d\n", NCS, CI)); alg_p->n_com_sizes = NCS; alg_p->com_rules = ompi_coll_tuned_mk_com_rules (NCS, CI); + if (NULL == alg_p->com_rules) { + OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate com rules for file [%s]\n", fname)); + goto on_file_error; + } for (ncs=0;ncsn_msg_sizes = NMS; com_p->msg_rules = ompi_coll_tuned_mk_msg_rules (NMS, CI, ncs, CS); + if (NULL == com_p->msg_rules) { + OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate msg rules for file [%s]\n", fname)); + goto on_file_error; + } msg_p = com_p->msg_rules;