Skip to content

Commit cd2b5a8

Browse files
committed
hwloc: plug memory leak
as reported by Coverity with CID 1270441
1 parent e2c343c commit cd2b5a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

opal/mca/hwloc/base/hwloc_base_util.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,20 +2061,25 @@ int opal_hwloc_get_sorted_numa_list(hwloc_topology_t topo, char* device_name, op
20612061
}else {
20622062
/* don't already know it - go get it */
20632063
/* firstly we check if we need to autodetect OpenFabrics devices or we have the specified one */
2064+
bool free_device_name = false;
20642065
if (!strcmp(device_name, "auto")) {
20652066
count = find_devices(topo, &device_name);
20662067
if (count > 1) {
20672068
free(device_name);
20682069
return count;
20692070
}
2071+
free_device_name = true;
20702072
}
20712073
if (!device_name) {
20722074
return OPAL_ERR_NOT_FOUND;
2073-
} else if (strlen(device_name) == 0) {
2075+
} else if (free_device_name && (0 == strlen(device_name))) {
20742076
free(device_name);
20752077
return OPAL_ERR_NOT_FOUND;
20762078
}
20772079
sort_by_dist(topo, device_name, sorted_list);
2080+
if (free_device_name) {
2081+
free(device_name);
2082+
}
20782083
/* store this info in summary object for later usage */
20792084
OPAL_LIST_FOREACH(numa, sorted_list, opal_rmaps_numa_node_t) {
20802085
copy_numa = OBJ_NEW(opal_rmaps_numa_node_t);

0 commit comments

Comments
 (0)