From 4f69189fe7176b1740a149fabfe848f6d2b48d8e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 30 Jan 2012 23:27:23 +0100 Subject: [PATCH] libmount: fix resource leak [coverity scan] Signed-off-by: Karel Zak --- libmount/src/utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 0bd7c361b5..823289e5f9 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -427,6 +427,7 @@ err: static int get_filesystems(const char *filename, char ***filesystems, const char *pattern) { + int rc = 0; FILE *f; char line[128]; @@ -436,7 +437,6 @@ static int get_filesystems(const char *filename, char ***filesystems, const char while (fgets(line, sizeof(line), f)) { char name[sizeof(line)]; - int rc; if (*line == '#' || strncmp(line, "nodev", 5) == 0) continue; @@ -446,9 +446,11 @@ static int get_filesystems(const char *filename, char ***filesystems, const char continue; rc = add_filesystem(filesystems, name); if (rc) - return rc; + break; } - return 0; + + fclose(f); + return rc; } int mnt_get_filesystems(char ***filesystems, const char *pattern) -- 2.47.3