From 45d04a7a90d0a380e75070ec155eceb1253c3791 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Sun, 25 Jan 2015 22:38:50 +0900 Subject: [PATCH 1/3] lib/libhammer: fix minor memory leaks This patch fixes minor memory leaks of libhammer. hunk1: This isn't necessary since it never gets here. _libhammer_malloc() exit(1) if it failed to calloc(). hunk2: Add missing close(fd). hunk3: Add missing free(mntbuf). --- lib/libhammer/misc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/libhammer/misc.c b/lib/libhammer/misc.c index 03751ab..9a0d0f2 100644 --- a/lib/libhammer/misc.c +++ b/lib/libhammer/misc.c @@ -66,10 +66,6 @@ libhammer_find_pfs_mount(int pfsid, uuid_t parentuuid, int ismaster) mntbufsize = (mntsize) * sizeof(struct statfs); mntbuf = _libhammer_malloc(mntbufsize); - if (mntbuf == NULL) { - perror("show_info"); - exit(EXIT_FAILURE); - } mntsize = getfsstat(mntbuf, (long)mntbufsize, MNT_NOWAIT); curmount = mntsize - 1; @@ -93,6 +89,7 @@ libhammer_find_pfs_mount(int pfsid, uuid_t parentuuid, int ismaster) } if ((ioctl(fd, HAMMERIOC_GET_INFO, &hi)) < 0) { + close(fd); curmount--; continue; } @@ -119,6 +116,7 @@ libhammer_find_pfs_mount(int pfsid, uuid_t parentuuid, int ismaster) close(fd); } free(trailstr); + free(mntbuf); return retval; } -- 2.1.2