Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3725b35f authored by Yu Kuai's avatar Yu Kuai Committed by Greg Kroah-Hartman
Browse files

md/raid10: fix memleak of md thread



[ Upstream commit f0ddb83da3cbbf8a1f9087a642c448ff52ee9abd ]

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: 43a52123 ("md-cluster: choose correct label when clustered layout is not supported")
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230310073855.1337560-7-yukuai1@huaweicloud.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fb3f2f2f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3769,6 +3769,9 @@ static int raid10_run(struct mddev *mddev)
	if (!conf)
		goto out;

	mddev->thread = conf->thread;
	conf->thread = NULL;

	if (mddev_is_clustered(conf->mddev)) {
		int fc, fo;

@@ -3781,9 +3784,6 @@ static int raid10_run(struct mddev *mddev)
		}
	}

	mddev->thread = conf->thread;
	conf->thread = NULL;

	if (mddev->queue) {
		blk_queue_max_discard_sectors(mddev->queue,
					      mddev->chunk_sectors);