This is a note to let you know that I've just added the patch titled mmc: mmc_spi: fix error handling in mmc_spi_probe() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mmc-mmc_spi-fix-error-handling-in-mmc_spi_probe.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From cf4c9d2ac1e42c7d18b921bec39486896645b714 Mon Sep 17 00:00:00 2001 From: Yang Yingliang <yangyingliang@xxxxxxxxxx> Date: Tue, 31 Jan 2023 09:38:35 +0800 Subject: mmc: mmc_spi: fix error handling in mmc_spi_probe() From: Yang Yingliang <yangyingliang@xxxxxxxxxx> commit cf4c9d2ac1e42c7d18b921bec39486896645b714 upstream. 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_request'. Fixes: 15a0580ced08 ("mmc_spi host driver") Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> Cc:stable@xxxxxxxxxxxxxxx Link: https://lore.kernel.org/r/20230131013835.3564011-1-yangyingliang@xxxxxxxxxx Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/mmc/host/mmc_spi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1441,7 +1441,7 @@ static int mmc_spi_probe(struct spi_devi status = mmc_add_host(mmc); if (status != 0) - goto fail_add_host; + goto fail_glue_init; /* * Index 0 is card detect @@ -1449,7 +1449,7 @@ static int mmc_spi_probe(struct spi_devi */ status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1000); if (status == -EPROBE_DEFER) - goto fail_add_host; + goto fail_gpiod_request; if (!status) { /* * The platform has a CD GPIO signal that may support @@ -1464,7 +1464,7 @@ static int mmc_spi_probe(struct spi_devi /* 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_request; if (!status) has_ro = true; @@ -1478,7 +1478,7 @@ static int mmc_spi_probe(struct spi_devi ? ", cd polling" : ""); return 0; -fail_add_host: +fail_gpiod_request: mmc_remove_host(mmc); fail_glue_init: mmc_spi_dma_free(host); Patches currently in stable-queue which might be from yangyingliang@xxxxxxxxxx are queue-5.15/mmc-mmc_spi-fix-error-handling-in-mmc_spi_probe.patch queue-5.15/mmc-sdio-fix-possible-resource-leaks-in-some-error-paths.patch