* [PATCH 5.10] mmc: rtsx_pci: fix return value check of mmc_add_host()
@ 2026-11-24 9:41 Denis Arefev
0 siblings, 0 replies; only message in thread
From: Denis Arefev @ 2026-11-24 9:41 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman
Cc: Ulf Hansson, Matthew Schwartz, Sasha Levin, Florian Maillard,
Arnd Bergmann, Wei WANG, Samuel Ortiz, linux-mmc, linux-kernel,
lvc-project, Yang Yingliang
From: Yang Yingliang <yangyingliang@huawei.com>
commit 0c87db77423a282b3b38b8a6daf057b822680516 upstream.
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>
[Denis Arefev: adapted for 5.10: the pm_runtime_dont_use_autosuspend() and
pm_runtime_disable() calls present in the upstream commit are not
included, since runtime PM support was never added to the rtsx_pci_sdmmc
driver in this tree (the probe/remove path has no pm_runtime calls).]
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
drivers/mmc/host/rtsx_pci_sdmmc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index f0e9a7667994..161bc5b98ed6 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1439,6 +1439,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
struct realtek_pci_sdmmc *host;
struct rtsx_pcr *pcr;
struct pcr_handle *handle = pdev->dev.platform_data;
+ int ret;
if (!handle)
return -ENXIO;
@@ -1469,7 +1470,11 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
realtek_init_host(host);
- mmc_add_host(mmc);
+ ret = mmc_add_host(mmc);
+ if (ret) {
+ mmc_free_host(mmc);
+ return ret;
+ }
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 9:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 9:41 [PATCH 5.10] mmc: rtsx_pci: fix return value check of mmc_add_host() Denis Arefev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®