summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-11-06 17:15:44 -0600
committerChris Mason <chris.mason@fusionio.com>2013-11-07 16:10:41 -0500
commit9dc137918f3a3346bb2c6ef3de6033d5688c037b (patch)
tree075aa14a197b02bdcf09eb98216e7f57aede7b41
parent12c3c9509b79b9e99c8e907f199781a2b097b6e5 (diff)
btrfs-progs: don't leak fd in test_dev_for_mkfs() error paths
Close fd before we return on error paths. Resolves-Coverity-CID: 1125939 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--utils.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 47ba23b6..9af49f70 100644
--- a/utils.c
+++ b/utils.c
@@ -1928,10 +1928,12 @@ int test_dev_for_mkfs(char *file, int force_overwrite, char *estr)
if (fstat(fd, &st)) {
snprintf(estr, sz, "unable to stat %s: %s\n", file,
strerror(errno));
+ close(fd);
return 1;
}
if (!S_ISBLK(st.st_mode)) {
fprintf(stderr, "'%s' is not a block device\n", file);
+ close(fd);
return 1;
}
close(fd);