From: Karel Zak Date: Mon, 30 Jan 2012 22:27:23 +0000 (+0100) Subject: libmount: fix resource leak [coverity scan] X-Git-Tag: v2.21-rc2~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f69189fe7176b1740a149fabfe848f6d2b48d8e;p=thirdparty%2Futil-linux.git libmount: fix resource leak [coverity scan] Signed-off-by: Karel Zak --- 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)