summaryrefslogtreecommitdiff
path: root/btrfs-find-root.c
diff options
context:
space:
mode:
Diffstat (limited to 'btrfs-find-root.c')
-rw-r--r--btrfs-find-root.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 810d8358..3e1396d3 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -76,7 +76,10 @@ static int close_all_devices(struct btrfs_fs_info *fs_info)
list = &fs_info->fs_devices->devices;
list_for_each(next, list) {
device = list_entry(next, struct btrfs_device, dev_list);
- close(device->fd);
+ if (device->fd != -1) {
+ close(device->fd);
+ device->fd = -1;
+ }
}
return 0;
}