From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-mmc@vger.kernel.org>
Cc: <ulf.hansson@linaro.org>, <yangyingliang@huawei.com>
Subject: [PATCH 1/9] mmc: alcor: fix return value check of mmc_add_host()
Date: Tue, 1 Nov 2022 14:30:15 +0800 [thread overview]
Message-ID: <20221101063023.1664968-2-yangyingliang@huawei.com> (raw)
In-Reply-To: <20221101063023.1664968-1-yangyingliang@huawei.com>
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.
Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/mmc/host/alcor.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
index bfb8efeb7eb8..d01df01d4b4d 100644
--- a/drivers/mmc/host/alcor.c
+++ b/drivers/mmc/host/alcor.c
@@ -1114,7 +1114,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
alcor_hw_init(host);
dev_set_drvdata(&pdev->dev, host);
- mmc_add_host(mmc);
+ ret = mmc_add_host(mmc);
+ if (ret)
+ goto free_host;
+
return 0;
free_host:
--
2.25.1
next prev parent reply other threads:[~2022-11-01 6:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 6:30 [PATCH 0/9] mmc: fix return value check of mmc_add_host() Yang Yingliang
2022-11-01 6:30 ` Yang Yingliang [this message]
2022-11-01 6:30 ` [PATCH 2/9] mmc: moxart: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 3/9] mmc: mxcmmc: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 4/9] mmc: pxamci: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 5/9] mmc: rtsx_pci: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 6/9] mmc: rtsx_usb_sdmmc: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 7/9] mmc: toshsd: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 8/9] mmc: vub300: " Yang Yingliang
2022-11-01 6:30 ` [PATCH 9/9] mmc: wmt-sdmmc: " Yang Yingliang
2022-11-08 16:05 ` [PATCH 0/9] mmc: " Ulf Hansson
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=20221101063023.1664968-2-yangyingliang@huawei.com \
--to=yangyingliang@huawei.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.