mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Denis Arefev <arefev@swemel.ru>
To: stable@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Matthew Schwartz <matthew.schwartz@linux.dev>,
	Sasha Levin <sashal@kernel.org>,
	Florian Maillard <florian.maillard@mailoo.org>,
	Arnd Bergmann <arnd@arndb.de>, Wei WANG <wei_wang@realsil.com.cn>,
	Samuel Ortiz <sameo@linux.intel.com>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org,
	Yang Yingliang <yangyingliang@huawei.com>
Subject: [PATCH 5.10] mmc: rtsx_pci: fix return value check of mmc_add_host()
Date: Tue, 24 Nov 2026 12:41:46 +0300	[thread overview]
Message-ID: <20261124094148.96655-1-arefev@swemel.ru> (raw)

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


                 reply	other threads:[~2026-11-24  9:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124094148.96655-1-arefev@swemel.ru \
    --to=arefev@swemel.ru \
    --cc=arnd@arndb.de \
    --cc=florian.maillard@mailoo.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=matthew.schwartz@linux.dev \
    --cc=sameo@linux.intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wei_wang@realsil.com.cn \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®