diff options
| author | Zilin Guan <zilin@seu.edu.cn> | 2026-01-26 07:15:33 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-02-26 14:59:01 -0800 |
| commit | ec10e3dc93994b87adf7c759a4639fe34013989a (patch) | |
| tree | b81b7646cf05dd19c9c49f079dd72912c189cd90 /drivers/md/raid1.c | |
| parent | 02455f658db8e32cc4ae9adb9c2ff6d1b80bb0b0 (diff) | |
| download | linux-ec10e3dc93994b87adf7c759a4639fe34013989a.tar.gz linux-ec10e3dc93994b87adf7c759a4639fe34013989a.tar.bz2 linux-ec10e3dc93994b87adf7c759a4639fe34013989a.zip | |
md/raid1: fix memory leak in raid1_run()
[ Upstream commit 6abc7d5dcf0ee0f85e16e41c87fbd06231f28753 ]
raid1_run() calls setup_conf() which registers a thread via
md_register_thread(). If raid1_set_limits() fails, the previously
registered thread is not unregistered, resulting in a memory leak
of the md_thread structure and the thread resource itself.
Add md_unregister_thread() to the error path to properly cleanup
the thread, which aligns with the error handling logic of other paths
in this function.
Compile tested only. Issue found using a prototype static analysis tool
and code review.
Link: https://lore.kernel.org/linux-raid/20260126071533.606263-1-zilin@seu.edu.cn
Fixes: 97894f7d3c29 ("md/raid1: use the atomic queue limit update APIs")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: Li Nan <linan122@huawei.com>
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md/raid1.c')
| -rw-r--r-- | drivers/md/raid1.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 592a40233004..ce7fd6886956 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -3253,6 +3253,7 @@ static int raid1_run(struct mddev *mddev) if (!mddev_is_dm(mddev)) { ret = raid1_set_limits(mddev); if (ret) { + md_unregister_thread(mddev, &conf->thread); if (!mddev->private) raid1_free(mddev, conf); return ret; |
