From 9e769c4864234a22d2e01a0a1cf7d3bac2db8b5c Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 4 Mar 2013 16:39:52 -0600 Subject: [PATCH] btrfs-progs: close fd on do_convert error returns stops an fd leak that Coverity found. Signed-off-by: Eric Sandeen --- convert.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/convert.c b/convert.c index 2b3f42f2..4a758958 100644 --- a/convert.c +++ b/convert.c @@ -2277,7 +2277,8 @@ err: int do_convert(const char *devname, int datacsum, int packing, int noxattr) { - int i, fd, ret; + int i, ret; + int fd = -1; u32 blocksize; u64 blocks[7]; u64 total_bytes; @@ -2407,6 +2408,8 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) printf("conversion complete.\n"); return 0; fail: + if (fd != -1) + close(fd); fprintf(stderr, "conversion aborted.\n"); return -1; }