mmc: rtsx_pci: fix return value check of mmc_add_host()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 1 Nov 2022 06:30:19 +0000 (14:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:16 +0000 (13:14 +0100)
commit30dc645461dfc63e52b3af8ee4a98e17bf14bacf
treeb1f1a956ef3e309bba534009b5354ce2fa728c83
parentbc7e8744f581552e81fa9b228c59f228b34052c4
mmc: rtsx_pci: fix return value check of mmc_add_host()

[ Upstream commit 0c87db77423a282b3b38b8a6daf057b822680516 ]

mmc_add_host() may return error, if we ignore its return value, the memory
that allocated in mmc_alloc_host() will be leaked and it will lead a kernel
crash because of deleting not added device in the remove path.

So fix this by checking the return value and calling mmc_free_host() in the
error path, beside, runtime PM also needs be disabled.

Fixes: ff984e57d36e ("mmc: Add realtek pcie sdmmc host driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221101063023.1664968-6-yangyingliang@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mmc/host/rtsx_pci_sdmmc.c