Skip to content

Commit 1cba0cd

Browse files
KAGA-KOKOChris Mason
authored andcommitted
btrfs: Init io_lock after cloning btrfs device struct
__btrfs_close_devices() clones btrfs device structs with memcpy(). Some of the fields in the clone are reinitialized, but it's missing to init io_lock. In mainline this goes unnoticed, but on RT it leaves the plist pointing to the original about to be freed lock struct. Initialize io_lock after cloning, so no references to the original struct are left. Reported-and-tested-by: Mike Galbraith <efault@gmx.de> Cc: stable@vger.kernel.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
1 parent e942f88 commit 1cba0cd

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/btrfs/volumes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
650650
new_device->writeable = 0;
651651
new_device->in_fs_metadata = 0;
652652
new_device->can_discard = 0;
653+
spin_lock_init(&new_device->io_lock);
653654
list_replace_rcu(&device->dev_list, &new_device->dev_list);
654655

655656
call_rcu(&device->rcu, free_device);

0 commit comments

Comments
 (0)