]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mmc: rtsx_usb_sdmmc: fix return value check of mmc_add_host()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 1 Nov 2022 06:30:20 +0000 (14:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:19 +0000 (12:07 +0100)
commitd7ad7278be401b09c9f9a9f522cf4c449c7fd489
tree24a21759af0c1612b353bd634670131cfff9dd94
parent5f35c038c9f4d258b3cf77885a2730f1417d63e7
mmc: rtsx_usb_sdmmc: fix return value check of mmc_add_host()

[ Upstream commit fc38a5a10e9e5a75eb9189854abeb8405b214cc9 ]

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, besides, led_classdev_unregister() and pm_runtime_disable() also
need be called.

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