close_fs_devices() will be able to return an error instead of crashing
after the following patch.
Prepare btrfs_close_devices() for this.
Signed-off-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
---
fs/btrfs/volumes.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e5864ca3bb3b..be1fd935edf7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1143,10 +1143,10 @@ static int close_fs_devices(struct btrfs_fs_devices *fs_devices)
int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
{
struct btrfs_fs_devices *seed_devices = NULL;
- int ret;
+ int err, err2 = 0;
mutex_lock(&uuid_mutex);
- ret = close_fs_devices(fs_devices);
+ err = close_fs_devices(fs_devices);
if (!fs_devices->opened) {
seed_devices = fs_devices->seed;
fs_devices->seed = NULL;
@@ -1156,10 +1156,13 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
while (seed_devices) {
fs_devices = seed_devices;
seed_devices = fs_devices->seed;
- close_fs_devices(fs_devices);
+ err2 = close_fs_devices(fs_devices);
free_fs_devices(fs_devices);
}
- return ret;
+
+ if (err2)
+ return err2;
+ return err;
}
static int open_fs_devices(struct btrfs_fs_devices *fs_devices,
--
2.16.4