md: don't rely on 'mddev->pers' to be set in mddev_suspend()
authorYu Kuai <yukuai3@huawei.com>
Fri, 25 Aug 2023 03:09:52 +0000 (11:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:19:39 +0000 (17:19 +0000)
commit20c2d2c323bcdcd3c1e9fbf67a0f5e77cb094a14
tree3e92a7e78ea75ddecb9cd308de18f6ecff2f2265
parentd78c4efaeb2d9ad53545e28460adda0685d80ae4
md: don't rely on 'mddev->pers' to be set in mddev_suspend()

[ Upstream commit b721e7885eb242aa2459ee66bb42ceef1bcf0f0c ]

'active_io' used to be initialized while the array is running, and
'mddev->pers' is set while the array is running as well. Hence caller
must hold 'reconfig_mutex' and guarantee 'mddev->pers' is set before
calling mddev_suspend().

Now that 'active_io' is initialized when mddev is allocated, such
restriction doesn't exist anymore. In the meantime, follow up patches
will refactor mddev_suspend(), hence add checking for 'mddev->pers' to
prevent null-ptr-deref.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230825030956.1527023-4-yukuai1@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/md.c