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>
This commit is contained in:
parent
12c3c9509b
commit
9dc137918f
2
utils.c
2
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);
|
||||
|
|
Loading…
Reference in New Issue