From patchwork Sat Nov 5 19:45:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9413791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9964D60723 for ; Sat, 5 Nov 2016 19:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82B3429344 for ; Sat, 5 Nov 2016 19:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 779042936F; Sat, 5 Nov 2016 19:45:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDC4429347 for ; Sat, 5 Nov 2016 19:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756660AbcKETpm (ORCPT ); Sat, 5 Nov 2016 15:45:42 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33794 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756848AbcKETpk (ORCPT ); Sat, 5 Nov 2016 15:45:40 -0400 Received: by mail-qt0-f196.google.com with SMTP id l20so4153234qta.1 for ; Sat, 05 Nov 2016 12:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=DDOB2RSkmDO2W28JmiA280ZHWq+d5e9WUy7s23DUQ8E=; b=BsRfPIbr2LFmgQJ+H8nuAtC8Vq/mrbK1Sx3wsrmhLXgRRhZxYhgnSZNnxuRJ7L453E iqW7llbL4gcUrbO0cqe8gAi/Mhff3JhLiQg3JHjJzoeLY9uwgkYZNTMWBkofvBLdQdeT YHXtrJfP+bW2ieQ6jI9P/MXYLS+ZJs1GG1JuSSC1iUS1jtGEyMUr38P2Cq1A4qNQ9V/X Vo3LwyfEjM9gEXSyOaZE5YeNOEC1TPyHg4BaKDFyyIbwDvHlpNeUNykYOEe2e+F5o+1X dk22pcGgQbdXoQmxx0/IaDb2SeyW3F9ORrQlCzGLPH9BCQkNr35fwxYfkd0CDmvFRcu7 f/8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DDOB2RSkmDO2W28JmiA280ZHWq+d5e9WUy7s23DUQ8E=; b=KAQC6+wln8N24StvWVjK/gVw5mzSnRBrL0MWxj2/v6LZUDwEbqR4Pv7sVvMvLcvHrT A1RlxMlF59XrlcACCv/dRokIeF3wQF9jmCethHgvb+B4RZdYBk4MxVaPMNYJW7ogM2d3 a0FAQR2INKi0tUfYBRwK5TTRsECf/zFRT5P6noEGIqv+NtMS9DwLMkMbtSC9ccotsHxj /snZE/oOQOUoZ4j/u54znqaHXvO11Ub767OifseCf9H9IvNtSF9Ej5M5OmJcCIYHU8+f 9YfTpOzBY8373ggBYhQzYpE8io1iqj9heGwEo+tTTRFNqTcHZmZ6R7puRv9PoZVLnmXC gprw== X-Gm-Message-State: ABUngvcDgqp0JLs49m7ekuasiSeckwGQD6WyEcYCQbfRXn69YbCDI1meNCncYcJ+Lcq93g== X-Received: by 10.200.50.227 with SMTP id a32mr20432307qtb.32.1478375139589; Sat, 05 Nov 2016 12:45:39 -0700 (PDT) Received: from localhost.localdomain ([187.180.187.87]) by smtp.gmail.com with ESMTPSA id a54sm11631818qta.49.2016.11.05.12.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Nov 2016 12:45:39 -0700 (PDT) From: Fabio Estevam To: ulf.hansson@linaro.org Cc: kernel@pengutronix.de, marex@denx.de, stefan.wahren@i2se.com, linux-mmc@vger.kernel.org, Fabio Estevam Subject: [PATCH v3] mmc: mxs: Initialize the spinlock prior to using it Date: Sat, 5 Nov 2016 17:45:07 -0200 Message-Id: <1478375107-32513-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam 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 Reviewed-by: Marek Vasut --- 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(-) diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index d839147..44ecebd 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -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;