[PATCH 3.16 213/306] mmc: mxs: Initialize the spinlock prior to using it

From: Ben Hutchings
Date: Wed Feb 15 2017 - 18:15:29 EST

3.16.40-rc1 review patch. If anyone has any objections, please let me know.


From: Fabio Estevam <fabio.estevam@xxxxxxx>

commit f91346e8b5f46aaf12f1df26e87140584ffd1b3f upstream.

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)
Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxx>
Reviewed-by: Marek Vasut <marex@xxxxxxx>
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
[bwh: Backported to 3.16 adjust context]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
drivers/mmc/host/mxs-mmc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -658,13 +658,13 @@ static int mxs_mmc_probe(struct platform

platform_set_drvdata(pdev, mmc);

+ spin_lock_init(&host->lock);
ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
if (ret)
goto out_free_dma;

- spin_lock_init(&host->lock);
ret = mmc_add_host(mmc);
if (ret)
goto out_free_dma;