Skip to content

Commit

Permalink
mtl/psm2: plug a memory leak in ompi_mtl_psm2_component_open()
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Gouaillardet <[email protected]>
  • Loading branch information
ggouaillardet committed Jan 6, 2017
1 parent b343df4 commit 1daa80d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ompi/mca/mtl/psm2/mtl_psm2_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Copyright (c) 2012-2015 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -102,16 +104,24 @@ ompi_mtl_psm2_component_register(void)
static int
ompi_mtl_psm2_component_open(void)
{
int res;
glob_t globbuf;
globbuf.gl_offs = 0;

/* Component available only if Omni-Path hardware is present */
if ((glob("/dev/hfi1_[0-9]", GLOB_DOOFFS, NULL, &globbuf) != 0) &&
(glob("/dev/hfi1_[0-9][0-9]", GLOB_APPEND, NULL, &globbuf) != 0)) {
return OPAL_ERR_NOT_AVAILABLE;
res = glob("/dev/hfi1_[0-9]", GLOB_DOOFFS, NULL, &globbuf);
if (0 == res || GLOB_NOMATCH == res) {
globfree(&globbuf);
}
if (0 != res) {
res = glob("/dev/hfi1_[0-9][0-9]", GLOB_APPEND, NULL, &globbuf);
if (0 == res || GLOB_NOMATCH == res) {
globfree(&globbuf);
}
if (0 != res) {
return OPAL_ERR_NOT_AVAILABLE;
}
}

globfree(&globbuf);

/* Component available only if at least one hfi1 port is ACTIVE */
bool foundOnlineHfi1Port = false;
Expand Down

0 comments on commit 1daa80d

Please sign in to comment.