diff mbox series

[3/4] btrfs: Remove redundant code from btrfs_free_stale_devices

Message ID 20200722080925.6802-4-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series Misc cleanups around device addition | expand

Commit Message

Nikolay Borisov July 22, 2020, 8:09 a.m. UTC
Following the refactor of btrfs_free_stale_devices in
7bcb8164ad94 ("btrfs: use device_list_mutex when removing stale devices")
fs_devices are freed after they have been iterated by the inner
list_for_each so the UAF fixed by introducing the break in
fd649f10c3d2 ("btrfs: Fix use-after-free when cleaning up fs_devs with
a single stale device") is no longer necessary. Just remove it
altogether. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/volumes.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Anand Jain July 30, 2020, 5:01 a.m. UTC | #1
On 22/7/20 4:09 pm, Nikolay Borisov wrote:
> Following the refactor of btrfs_free_stale_devices in
> 7bcb8164ad94 ("btrfs: use device_list_mutex when removing stale devices")
> fs_devices are freed after they have been iterated by the inner
> list_for_each so the UAF fixed by introducing the break in
> fd649f10c3d2 ("btrfs: Fix use-after-free when cleaning up fs_devs with
> a single stale device") is no longer necessary. Just remove it
> altogether. No functional changes.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>   fs/btrfs/volumes.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 384614fe0e2a..17047c118969 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -588,8 +588,6 @@ static int btrfs_free_stale_devices(const char *path,
>   			btrfs_free_device(device);
>   
>   			ret = 0;
> -			if (fs_devices->num_devices == 0)
> -				break;
>   		}
>   		mutex_unlock(&fs_devices->device_list_mutex);
>   
> 


Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 384614fe0e2a..17047c118969 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -588,8 +588,6 @@  static int btrfs_free_stale_devices(const char *path,
 			btrfs_free_device(device);
 
 			ret = 0;
-			if (fs_devices->num_devices == 0)
-				break;
 		}
 		mutex_unlock(&fs_devices->device_list_mutex);