md/raid10: fix memleak of md thread
authorYu Kuai <yukuai3@huawei.com>
Fri, 10 Mar 2023 07:38:55 +0000 (15:38 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:23 +0000 (23:03 +0900)
commit36ba0c7b86acd9c2ea80a273204d52c21c955471
treec5be36b2554029ccca229508f672ab16a24a05fa
parentb21019a220d9cac08819bb6c63000de9ee61eb9e
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: 43a521238aca ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/raid10.c