Skip to content

Commit 825711e

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid10: fix null ptr dereference in raid10_size()
In raid10_run() if raid10_set_queue_limits() succeed, the return value is set to zero, and if following procedures failed raid10_run() will return zero while mddev->private is still NULL, causing null ptr dereference in raid10_size(). Fix the problem by only overwrite the return value if raid10_set_queue_limits() failed. Fixes: 3d8466b ("md/raid10: use the atomic queue limit update APIs") Cc: stable@vger.kernel.org Reported-and-tested-by: ValdikSS <iam@valdikss.org.ru> Closes: https://lore.kernel.org/all/0dd96820-fe52-4841-bc58-dbf14d6bfcc8@valdikss.org.ru/ Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20241009014914.1682037-1-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org>
1 parent 62ce078 commit 825711e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/md/raid10.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,9 +4061,12 @@ static int raid10_run(struct mddev *mddev)
40614061
}
40624062

40634063
if (!mddev_is_dm(conf->mddev)) {
4064-
ret = raid10_set_queue_limits(mddev);
4065-
if (ret)
4064+
int err = raid10_set_queue_limits(mddev);
4065+
4066+
if (err) {
4067+
ret = err;
40664068
goto out_free_conf;
4069+
}
40674070
}
40684071

40694072
/* need to check that every block has at least one working mirror */

0 commit comments

Comments
 (0)