From da7ffb64488f6200b480f2ad0a07635c496cacb8 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 16 Feb 2015 13:51:05 +0900 Subject: [PATCH] btl/vader: fix memory leak as reported by Coverity with CID 1269904 --- opal/mca/btl/vader/btl_vader_module.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opal/mca/btl/vader/btl_vader_module.c b/opal/mca/btl/vader/btl_vader_module.c index 2f30cd3071..aab71458b4 100644 --- a/opal/mca/btl/vader/btl_vader_module.c +++ b/opal/mca/btl/vader/btl_vader_module.c @@ -15,7 +15,7 @@ * Copyright (c) 2010-2014 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science + * Copyright (c) 2014-2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -86,10 +86,14 @@ static int vader_btl_first_time_init(mca_btl_vader_t *vader_btl, int n) /* generate the endpoints */ component->endpoints = (struct mca_btl_base_endpoint_t *) calloc (n + 1, sizeof (struct mca_btl_base_endpoint_t)); + if (NULL == component->endpoints) { + return OPAL_ERR_OUT_OF_RESOURCE; + } component->endpoints[n].peer_smp_rank = -1; - component->fbox_in_endpoints = calloc (n + 1, sizeof (void *)); - if (NULL == component->endpoints || NULL == component->fbox_in_endpoints) { + component->fbox_in_endpoints = calloc (n + 1, sizeof (void *)); + if (NULL == component->fbox_in_endpoints) { + free(component->endpoints); return OPAL_ERR_OUT_OF_RESOURCE; }