[PATCH] mmc: sh_mmcif: initialize IRQ-thread mutex before requesting interrupt

Runyu Xiao posted 1 patch 3 weeks, 2 days ago
drivers/mmc/host/sh_mmcif.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] mmc: sh_mmcif: initialize IRQ-thread mutex before requesting interrupt
Posted by Runyu Xiao 3 weeks, 2 days ago
The threaded IRQ handler can run before devm_request_threaded_irq()
returns, but thread_lock was initialized afterwards. Initialize it before
requesting either interrupt.

Fixes: 8047310ee984 ("mmc: sh_mmcif: fix a race, causing an Oops on SMP")
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
 drivers/mmc/host/sh_mmcif.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 7706d01b1..8bd9cdeda 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1461,6 +1461,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 	host->pd = pdev;
 
 	spin_lock_init(&host->lock);
+	mutex_init(&host->thread_lock);
 
 	mmc->ops = &sh_mmcif_ops;
 	sh_mmcif_init_ocr(host);
@@ -1515,8 +1516,6 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 			goto err_clk;
 	}
 
-	mutex_init(&host->thread_lock);
-
 	ret = mmc_add_host(mmc);
 	if (ret < 0)
 		goto err_clk;
-- 
2.34.1
Re: [PATCH] mmc: sh_mmcif: initialize IRQ-thread mutex before requesting interrupt
Posted by Ulf Hansson 2 weeks ago
On Wed, Sep 2, 2026 at 4:09 PM Runyu Xiao <runyu.xiao@seu.edu.cn> wrote:
>
> The threaded IRQ handler can run before devm_request_threaded_irq()
> returns, but thread_lock was initialized afterwards. Initialize it before
> requesting either interrupt.
>
> Fixes: 8047310ee984 ("mmc: sh_mmcif: fix a race, causing an Oops on SMP")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sh_mmcif.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index 7706d01b1..8bd9cdeda 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -1461,6 +1461,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
>         host->pd = pdev;
>
>         spin_lock_init(&host->lock);
> +       mutex_init(&host->thread_lock);
>
>         mmc->ops = &sh_mmcif_ops;
>         sh_mmcif_init_ocr(host);
> @@ -1515,8 +1516,6 @@ static int sh_mmcif_probe(struct platform_device *pdev)
>                         goto err_clk;
>         }
>
> -       mutex_init(&host->thread_lock);
> -
>         ret = mmc_add_host(mmc);
>         if (ret < 0)
>                 goto err_clk;
> --
> 2.34.1
>