mirror of
https://github.com/torvalds/linux.git
synced 2026-11-10 17:11:02 +01:00
btrfs: zoned: fix block group reference leak in btrfs_repair_one_zone()
btrfs_repair_one_zone() hands the block group reference taken by
btrfs_lookup_block_group() over to relocating_repair_kthread(), which
drops it. However the return value of kthread_run() is not checked, so
when the kernel thread fails to spawn, nothing executes the put and the
block group reference is leaked.
Check kthread_run() and drop the reference if the thread failed to
start.
Fixes: f7ef5287a6 ("btrfs: zoned: relocate block group to repair IO failure in zoned filesystems")
CC: stable@vger.kernel.org
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
057e3c350a
commit
886f1aa6e6
|
|
@ -9006,6 +9006,7 @@ static int relocating_repair_kthread(void *data)
|
|||
bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
|
||||
{
|
||||
struct btrfs_block_group *cache;
|
||||
struct task_struct *task;
|
||||
|
||||
if (!btrfs_is_zoned(fs_info))
|
||||
return false;
|
||||
|
|
@ -9023,8 +9024,9 @@ bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
|
|||
return true;
|
||||
}
|
||||
|
||||
kthread_run(relocating_repair_kthread, cache,
|
||||
"btrfs-relocating-repair");
|
||||
task = kthread_run(relocating_repair_kthread, cache, "btrfs-relocating-repair");
|
||||
if (IS_ERR(task))
|
||||
btrfs_put_block_group(cache);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user