mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] mmc: sdio: fix kernel panic when remove non-standard SDIO card
@ 2022-10-14  3:49 Weizhao Ouyang
  2022-10-14 14:07 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Weizhao Ouyang @ 2022-10-14  3:49 UTC (permalink / raw)
  To: Ulf Hansson, Weizhao Ouyang, Matthew Ma, Sergey Shtylyov,
	John Wang, Andrew Morton, Grazvydas Ignotas
  Cc: linux-mmc, linux-kernel, Weizhao Ouyang

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-14 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14  3:49 [PATCH v2] mmc: sdio: fix kernel panic when remove non-standard SDIO card Weizhao Ouyang
2022-10-14 14:07 ` Ulf Hansson
2022-10-14 16:02   ` Weizhao Ouyang

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®