btrfs-progs: close fd on do_convert error returns

stops an fd leak that Coverity found.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
Eric Sandeen 2013-03-04 16:39:52 -06:00 committed by David Sterba
parent 0b9e200099
commit 9e769c4864
1 changed files with 4 additions and 1 deletions

View File

@ -2277,7 +2277,8 @@ err:
int do_convert(const char *devname, int datacsum, int packing, int noxattr) int do_convert(const char *devname, int datacsum, int packing, int noxattr)
{ {
int i, fd, ret; int i, ret;
int fd = -1;
u32 blocksize; u32 blocksize;
u64 blocks[7]; u64 blocks[7];
u64 total_bytes; u64 total_bytes;
@ -2407,6 +2408,8 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr)
printf("conversion complete.\n"); printf("conversion complete.\n");
return 0; return 0;
fail: fail:
if (fd != -1)
close(fd);
fprintf(stderr, "conversion aborted.\n"); fprintf(stderr, "conversion aborted.\n");
return -1; return -1;
} }