From: "Christian Löhle" <CLoehle@hyperstone.com>
To: Yang Yingliang <yangyingliang@huawei.com>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Cc: "ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
"drzeus@drzeus.cx" <drzeus@drzeus.cx>,
"david-b@pacbell.net" <david-b@pacbell.net>
Subject: RE: [PATCH] mmc: mmc_spi: fix error handling in mmc_spi_probe()
Date: Mon, 30 Jan 2023 14:12:13 +0000 [thread overview]
Message-ID: <b28fd5f063014da8bba7c052a8eaf4e9@hyperstone.com> (raw)
In-Reply-To: <20230130130106.3484864-1-yangyingliang@huawei.com>
fail_gpiod_reuqest has a typo, apart from that it looks reasonable.
-----Original Message-----
From: Yang Yingliang <yangyingliang@huawei.com>
Sent: Montag, 30. Januar 2023 14:01
To: linux-mmc@vger.kernel.org
Cc: ulf.hansson@linaro.org; drzeus@drzeus.cx; david-b@pacbell.net; yangyingliang@huawei.com
Subject: [PATCH] mmc: mmc_spi: fix error handling in mmc_spi_probe()
If mmc_add_host() fails, it doesn't need to call mmc_remove_host(), or it will cause null-ptr-deref, because of deleting a not added device in mmc_remove_host().
To fix this, goto label 'fail_glue_init', if mmc_add_host() fails, and change the label 'fail_add_host' to 'fail_gpiod_reuqest'.
Fixes: 15a0580ced08 ("mmc_spi host driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/mmc/host/mmc_spi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 75778ffd6cd4..3959c454ce48 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1437,7 +1437,7 @@ static int mmc_spi_probe(struct spi_device *spi)
status = mmc_add_host(mmc);
if (status != 0)
- goto fail_add_host;
+ goto fail_glue_init;
/*
* Index 0 is card detect
@@ -1445,7 +1445,7 @@ static int mmc_spi_probe(struct spi_device *spi)
*/
status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1000);
if (status == -EPROBE_DEFER)
- goto fail_add_host;
+ goto fail_gpiod_reuqest;
if (!status) {
/*
* The platform has a CD GPIO signal that may support @@ -1460,7 +1460,7 @@ static int mmc_spi_probe(struct spi_device *spi)
/* Index 1 is write protect/read only */
status = mmc_gpiod_request_ro(mmc, NULL, 1, 0);
if (status == -EPROBE_DEFER)
- goto fail_add_host;
+ goto fail_gpiod_reuqest;
if (!status)
has_ro = true;
@@ -1474,7 +1474,7 @@ static int mmc_spi_probe(struct spi_device *spi)
? ", cd polling" : "");
return 0;
-fail_add_host:
+fail_gpiod_reuqest:
mmc_remove_host(mmc);
fail_glue_init:
mmc_spi_dma_free(host);
--
2.25.1
Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
prev parent reply other threads:[~2023-01-30 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 13:01 [PATCH] mmc: mmc_spi: fix error handling in mmc_spi_probe() Yang Yingliang
2023-01-30 14:12 ` Christian Löhle [this message]
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=b28fd5f063014da8bba7c052a8eaf4e9@hyperstone.com \
--to=cloehle@hyperstone.com \
--cc=david-b@pacbell.net \
--cc=drzeus@drzeus.cx \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--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 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.