From d8f962242020ad781c272120125fb44ac6c37951 Mon Sep 17 00:00:00 2001 From: Thomas Stibor Date: Tue, 29 Jan 2019 16:09:07 +0100 Subject: [PATCH] LU-11899 utils: Possible resource/memory leaks Static checker revealed possible resource/memory leaks of file handle and process pipe. Signed-off-by: Thomas Stibor Change-Id: I4ee05a8325408370bcfb5e9b8d30253107115c7b Reviewed-on: https://review.whamcloud.com/34129 Tested-by: Jenkins Reviewed-by: Sebastien Buisson Reviewed-by: Shilong Wang Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/utils/gss/lsupport.c | 1 + lustre/utils/lfs_project.c | 1 + 2 files changed, 2 insertions(+) diff --git a/lustre/utils/gss/lsupport.c b/lustre/utils/gss/lsupport.c index e93c4e9..15eaa7c 100644 --- a/lustre/utils/gss/lsupport.c +++ b/lustre/utils/gss/lsupport.c @@ -246,6 +246,7 @@ int external_nid2hostname(char *lnd, uint32_t net, uint32_t addr, head = fgets(buf, bufsize, fghn); if (head == NULL) { printerr(0, "can't read from %s\n", gethostname_ex); + pclose(fghn); return -1; } if (pclose(fghn) == -1) diff --git a/lustre/utils/lfs_project.c b/lustre/utils/lfs_project.c index 03de7d5..d61b038 100644 --- a/lustre/utils/lfs_project.c +++ b/lustre/utils/lfs_project.c @@ -90,6 +90,7 @@ static int project_get_xattr(const char *pathname, struct fsxattr *fsx) if (ret) { fprintf(stderr, "%s: failed to get xattr for '%s': %s\n", progname, pathname, strerror(errno)); + close(fd); return -errno; } return fd; -- 1.8.3.1