summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Ma <mahongwei@zeku.com>2022-10-14 11:49:51 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-11-03 23:52:29 +0900
commit1fb79478695d92bab1c120ad3dad05252b02a29d (patch)
treecdfebf7dd9bd33d9c961abb69aade1eb8e45b280
parent3c43f3ec731c233eb84b66199ee76dbf3ec6ecae (diff)
downloadlinux-stable-1fb79478695d92bab1c120ad3dad05252b02a29d.tar.gz
linux-stable-1fb79478695d92bab1c120ad3dad05252b02a29d.tar.bz2
linux-stable-1fb79478695d92bab1c120ad3dad05252b02a29d.zip
mmc: core: Fix kernel panic when remove non-standard SDIO card
commit 9972e6b404884adae9eec7463e30d9b3c9a70b18 upstream. SDIO tuple is only allocated for standard SDIO card, especially it causes memory corruption issues when the non-standard SDIO card has removed, which is because the card device's reference counter does not increase for it at sdio_init_func(), but all SDIO card device reference counter gets 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> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20221014034951.2300386-1-ouyangweizhao@zeku.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/mmc/core/sdio_bus.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index b6d8203e46eb..8aebdc4ff623 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -264,7 +264,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);