Skip to contentSkip to conversation

mmc: mxs: Initialize the spinlock prior to using it

PATCH Applied Fabio Estevam 2 participants 2 messages Nov 5, 2016 – Nov 7, 2016

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v3 1/1 mmc: mxs: Initialize the spinlock prior to using it

From: Fabio Estevam <[email protected]>

An interrupt may occur right after devm_request_irq() is called and prior to the spinlock initialization, leading to a kernel oops, as the interrupt handler uses the spinlock.

In order to prevent this problem, move the spinlock initialization prior to requesting the interrupts.

Fixes e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)

---
Changes since v2:
- Add a Fixes tag as suggested by Stefan Changes since v1:
- Make it a standalone patch instead of patch series
- Cc stable as suggested by Stefan

 drivers/mmc/host/mxs-mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +2 -2
index d839147..44ecebd 100644
@@ -661,13 +661,13 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mmc);
 
+	spin_lock_init(&host->lock);
+
 	ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
 			       dev_name(&pdev->dev), host);
 	if (ret)
 		goto out_free_dma;
 
-	spin_lock_init(&host->lock);
-
 	ret = mmc_add_host(mmc);
 	if (ret)
 		goto out_free_dma;
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

An interrupt may occur right after devm_request_irq() is called and prior to the spinlock initialization, leading to a kernel oops, as the interrupt handler uses the spinlock.

Quoted 6 lines

In order to prevent this problem, move the spinlock initialization prior to requesting the interrupts.

Fixes e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)

Thanks, applied for fixes!

Kind regards
Uffe

Quoted 33 lines

---
Changes since v2:
- Add a Fixes tag as suggested by Stefan Changes since v1:
- Make it a standalone patch instead of patch series
- Cc stable as suggested by Stefan

 drivers/mmc/host/mxs-mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mxs-mmc.c +2 -3
index d839147..44ecebd 100644
@@ -661,13 +661,13 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, mmc);
 
+       spin_lock_init(&host->lock);
+
        ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
                               dev_name(&pdev->dev), host);
        if (ret)
                goto out_free_dma;
 
-       spin_lock_init(&host->lock);
-
        ret = mmc_add_host(mmc);
        if (ret)
                goto out_free_dma;
--

2.7.4