From 5e2bc2c662c22f5cda4ddfe8214990770d202382 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 29 May 2015 08:44:03 -0600 Subject: [PATCH 1/3] btl/openib: fix coverity issue CID 1269821 Dereference null return value (NULL_RETURNS) This is another false positive that can be silenced by looping on opal_list_remove_first instead of using both opal_list_is_empty and opal_list_remove_first. Signed-off-by: Nathan Hjelm --- opal/mca/btl/openib/btl_openib_endpoint.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/opal/mca/btl/openib/btl_openib_endpoint.c b/opal/mca/btl/openib/btl_openib_endpoint.c index 540c3902c06..a4f84e08927 100644 --- a/opal/mca/btl/openib/btl_openib_endpoint.c +++ b/opal/mca/btl/openib/btl_openib_endpoint.c @@ -613,13 +613,13 @@ void mca_btl_openib_endpoint_connected(mca_btl_openib_endpoint_t *endpoint) opal_progress_event_users_decrement(); if(MCA_BTL_XRC_ENABLED) { - while(master && !opal_list_is_empty(&endpoint->ib_addr->pending_ep)) { - ep_item = opal_list_remove_first(&endpoint->ib_addr->pending_ep); - ep = (mca_btl_openib_endpoint_t *)ep_item; - if (OPAL_SUCCESS != - opal_btl_openib_connect_base_start(endpoint->endpoint_local_cpc, - ep)) { - BTL_ERROR(("Failed to connect pending endpoint\n")); + if (master) { + while (NULL != (ep_item = opal_list_remove_first(&endpoint->ib_addr->pending_ep))) { + ep = (mca_btl_openib_endpoint_t *)ep_item; + if (OPAL_SUCCESS != + opal_btl_openib_connect_base_start(endpoint->endpoint_local_cpc, ep)) { + BTL_ERROR(("Failed to connect pending endpoint\n")); + } } } OPAL_THREAD_UNLOCK(&endpoint->ib_addr->addr_lock); From 1d27b1f944c6ac7894a52960b4b18fd61c3cb8c1 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 29 May 2015 08:48:15 -0600 Subject: [PATCH 2/3] pmix/native: fix coverity issue CID 1269730 Dereference after null check (FORWARD_NULL) The code checked for cb == NULL before checking for a callback function but did not have the same protection around the OBJ_RELEASE(cb). Signed-off-by: Nathan Hjelm --- opal/mca/pmix/native/pmix_native.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opal/mca/pmix/native/pmix_native.c b/opal/mca/pmix/native/pmix_native.c index 781321235a4..7f98c911257 100644 --- a/opal/mca/pmix/native/pmix_native.c +++ b/opal/mca/pmix/native/pmix_native.c @@ -5,6 +5,8 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Mellanox Technologies, Inc. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -699,10 +701,12 @@ static void fencenb_cbfunc(opal_buffer_t *buf, void *cbdata) } /* if a callback was provided, execute it */ - if (NULL != cb && NULL != cb->cbfunc) { - cb->cbfunc(rc, NULL, cb->cbdata); + if (NULL != cb) { + if (NULL != cb->cbfunc) { + cb->cbfunc(rc, NULL, cb->cbdata); + } + OBJ_RELEASE(cb); } - OBJ_RELEASE(cb); } static int native_fence_nb(opal_process_name_t *procs, size_t nprocs, From 7b7993e40638271f72de18961dab204bd702b296 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 29 May 2015 09:02:56 -0600 Subject: [PATCH 3/3] pmix/base: fix coverity issue CID 1269707 Logically dead code (DEADCODE) Coverity is correct that tmp3 can never be NULL here. Deleted the dead code. Signed-off-by: Nathan Hjelm --- opal/mca/pmix/base/pmix_base_fns.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/opal/mca/pmix/base/pmix_base_fns.c b/opal/mca/pmix/base/pmix_base_fns.c index 0cd99b402ca..30d091d181a 100644 --- a/opal/mca/pmix/base/pmix_base_fns.c +++ b/opal/mca/pmix/base/pmix_base_fns.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Research Organization for Information Science @@ -424,11 +424,7 @@ int opal_pmix_base_cache_keys_locally(const opal_process_name_t* id, const char* kv->data.byte = *tmp3; break; case OPAL_STRING: - if (NULL != tmp3) { - kv->data.string = strdup(tmp3); - } else { - kv->data.string = NULL; - } + kv->data.string = strdup(tmp3); break; case OPAL_PID: kv->data.pid = strtoul(tmp3, NULL, 10);