All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weizhao Ouyang <ouyangweizhao@zeku.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Weizhao Ouyang <o451686892@gmail.com>,
	Matthew Ma <mahongwei@zeku.com>,
	Sergey Shtylyov <s.shtylyov@omp.ru>,
	John Wang <wangdayu@zeku.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Grazvydas Ignotas <notasas@gmail.com>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Weizhao Ouyang" <ouyangweizhao@zeku.com>
Subject: [PATCH v2] mmc: sdio: fix kernel panic when remove non-standard SDIO card
Date: Fri, 14 Oct 2022 11:49:51 +0800	[thread overview]
Message-ID: <20221014034951.2300386-1-ouyangweizhao@zeku.com> (raw)

From: Weizhao Ouyang <o451686892@gmail.com>

From: Matthew Ma <mahongwei@zeku.com>

SDIO tuple is only allocated for standard SDIO card, especially it
causes memory corruption issues when the non-standard SDIO card has
removed since the card device's reference counter does not increase for
it at sdio_init_func(), but all SDIO card device reference counter has
decreased at sdio_release_func().

Fixes: 6f51be3d37df ("sdio: allow non-standard SDIO cards")
Signed-off-by: Matthew Ma <mahongwei@zeku.com>
Reviewed-by: Weizhao Ouyang <ouyangweizhao@zeku.com>
Reviewed-by: John Wang <wangdayu@zeku.com>
---
Changes in v2:
-- update Fixes tag

 drivers/mmc/core/sdio_bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index c6268c38c69e..babf21a0adeb 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -291,7 +291,8 @@ static void sdio_release_func(struct device *dev)
 {
 	struct sdio_func *func = dev_to_sdio_func(dev);
 
-	sdio_free_func_cis(func);
+	if (!(func->card->quirks & MMC_QUIRK_NONSTD_SDIO))
+		sdio_free_func_cis(func);
 
 	kfree(func->info);
 	kfree(func->tmpbuf);
-- 
2.25.1


             reply	other threads:[~2022-10-14  3:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  3:49 Weizhao Ouyang [this message]
2022-10-14 14:07 ` [PATCH v2] mmc: sdio: fix kernel panic when remove non-standard SDIO card Ulf Hansson
2022-10-14 16:02   ` Weizhao Ouyang

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=20221014034951.2300386-1-ouyangweizhao@zeku.com \
    --to=ouyangweizhao@zeku.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mahongwei@zeku.com \
    --cc=notasas@gmail.com \
    --cc=o451686892@gmail.com \
    --cc=s.shtylyov@omp.ru \
    --cc=ulf.hansson@linaro.org \
    --cc=wangdayu@zeku.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.