Skip to content

Commit f0ddb83

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid10: fix memleak of md thread
In raid10_run(), if setup_conf() succeed and raid10_run() failed before setting 'mddev->thread', then in the error path 'conf->thread' is not freed. Fix the problem by setting 'mddev->thread' right after setup_conf(). Fixes: 43a5212 ("md-cluster: choose correct label when clustered layout is not supported") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20230310073855.1337560-7-yukuai1@huaweicloud.com
1 parent c9ac2ac commit f0ddb83

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/md/raid10.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,6 +4150,9 @@ static int raid10_run(struct mddev *mddev)
41504150
if (!conf)
41514151
goto out;
41524152

4153+
mddev->thread = conf->thread;
4154+
conf->thread = NULL;
4155+
41534156
if (mddev_is_clustered(conf->mddev)) {
41544157
int fc, fo;
41554158

@@ -4162,9 +4165,6 @@ static int raid10_run(struct mddev *mddev)
41624165
}
41634166
}
41644167

4165-
mddev->thread = conf->thread;
4166-
conf->thread = NULL;
4167-
41684168
if (mddev->queue) {
41694169
blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
41704170
blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);

0 commit comments

Comments
 (0)