Skip to content

Commit 97f02d1

Browse files
bgoglinndenoyelle
authored and
ndenoyelle
committed
linux: fix a mntent leak on failure to allocate a buffer
Signed-off-by: Brice Goglin <[email protected]>
1 parent 2f059eb commit 97f02d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hwloc/topology-linux.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2241,8 +2241,10 @@ hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, const
22412241
*/
22422242
bufsize = hwloc_getpagesize()*4;
22432243
buf = malloc(bufsize);
2244-
if (!buf)
2244+
if (!buf) {
2245+
endmntent(fd);
22452246
return;
2247+
}
22462248

22472249
while (getmntent_r(fd, &mntent, buf, bufsize)) {
22482250
if (!strcmp(mntent.mnt_type, "cpuset")) {

0 commit comments

Comments
 (0)