Signed-off-by: Anand Jain <anand.j...@oracle.com>
---
 mkfs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index 60f906c..66f558a 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1570,6 +1570,8 @@ int main(int ac, char **av)
                 * occur by the following processing.
                 * (btrfs_register_one_device() fails if O_EXCL is on)
                 */
+               if (fd > 0)
+                       close(fd);
                fd = open(file, O_RDWR);
                if (fd < 0) {
                        fprintf(stderr, "unable to open %s: %s\n", file,
@@ -1581,7 +1583,6 @@ int main(int ac, char **av)
                if (ret) {
                        fprintf(stderr, "skipping duplicate device %s in FS\n",
                                file);
-                       close(fd);
                        continue;
                }
                ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to