Skip to content

Commit

Permalink
linux: fix a mntent leak on failure to allocate a buffer
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Oct 21, 2019
1 parent dbede24 commit 3840d8c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hwloc/topology-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,8 +2241,10 @@ hwloc_find_linux_cpuset_mntpnt(char **cgroup_mntpnt, char **cpuset_mntpnt, const
*/
bufsize = hwloc_getpagesize()*4;
buf = malloc(bufsize);
if (!buf)
if (!buf) {
endmntent(fd);
return;
}

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

0 comments on commit 3840d8c

Please sign in to comment.