mnt_table_parse_dir in libmount/src/tab_parse.c calls scandir, and then opendir. When the latter one, opendir is failed, buffers allocated in scandir are not released. Signed-off-by: Masatake YAMATO <yamato@xxxxxxxxxx> --- libmount/src/tab_parse.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index 6cd66af..33aa7ef 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -431,7 +431,7 @@ int mnt_table_parse_file(struct libmnt_table *tb, const char *filename) static int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) { - int n = 0, i; + int n = 0, i, r = 0; DIR *dir = NULL; struct dirent **namelist = NULL; @@ -443,8 +443,10 @@ static int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) /* let use "at" functions rather than play crazy games with paths... */ dir = opendir(dirname); - if (!dir) - return -errno; + if (!dir) { + r = -errno; + goto out; + } for (i = 0; i < n; i++) { struct dirent *d = namelist[i]; @@ -480,12 +482,13 @@ static int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) } } +out: for (i = 0; i < n; i++) free(namelist[i]); free(namelist); if (dir) closedir(dir); - return 0; + return r; } struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt) -- 1.7.7.5 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html