From patchwork Sat Nov 5 19:23:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9413787 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 6B4556048F for ; Sat, 5 Nov 2016 19:23:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D56120564 for ; Sat, 5 Nov 2016 19:23:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EBF029681; Sat, 5 Nov 2016 19:23:57 +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 4E4F720564 for ; Sat, 5 Nov 2016 19:23:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755581AbcKETXy (ORCPT ); Sat, 5 Nov 2016 15:23:54 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:36763 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755084AbcKETXw (ORCPT ); Sat, 5 Nov 2016 15:23:52 -0400 Received: by mail-qt0-f193.google.com with SMTP id n34so4137159qtb.3; Sat, 05 Nov 2016 12:23:52 -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=+2jla9kxQOvf9kVexhGmNdiKHbSsNEC2aAtd9xXukT4=; b=0ib4POaWN7e14ZvJ9EWa1zXK+SOFWzan0Xz+cHm4SjyJiR9qUAysfGneVEl4ebmYR5 khAdzSjvG98crgqAAJRGk/8pnUXFUPYe3wohjGzrcPvaWKm1uZTS6RYcBo3a0/gdQrZp G4qgiqshf6nvVycBj1XUTnjOD5zFXD/VNNFRdVVmtlWq/fLNtycIJGjjhxFwNqeOj7fQ QlIxKPb+0vT/8kwkWbxfw1WNOYFYYptXB/SuFYjwGqINnK3ps/DN17IOjVOv8gedyMpd WP1NqiFn8oa+Vw+XNBoZZoON0OrssCyWeYvQNGc8UFWQuvKNNacNzGmLxR7WitAzmMfo AY+Q== 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=+2jla9kxQOvf9kVexhGmNdiKHbSsNEC2aAtd9xXukT4=; b=fXeOn/FDNwBoYIIAUSY6gToN7Ppl11Zb9g/GA+XJU8EpoYulNUDKuM3pljbAfN+LeO 9XB4fVC3IZy0dwkkCyzazw2R/avhi/wosU8qgELIcxAdQXN8Yzu3ze7NW5m9LAFAX8AS lrDuAxhkyXRKBIcRIlJwGtMce43I4JYqLs7eT2cysuGdhbhZH6y3/wKytF7vzWXVCAav 289uL4FrM4Ov4lc6K3XXGQA3fqy3ToOYrIfeJMgH6Zcokrz76avIy6AqN0ENwlZfDfAn oHr6TkfAW9NAPdnyitN/tu3gKf8vs8Gat09a/3KRbAnJqp7XC8+Op3109owbiF545JmD 8SgA== X-Gm-Message-State: ABUngvf/vX621HrBvumXWqcvd9KAV3/Rr6KWkIOF4WBBEkFYdoky3NNZhgu9k92vcLbqmg== X-Received: by 10.237.62.27 with SMTP id l27mr20641064qtf.34.1478373831557; Sat, 05 Nov 2016 12:23:51 -0700 (PDT) Received: from localhost.localdomain ([187.180.187.87]) by smtp.gmail.com with ESMTPSA id d127sm11602518qkf.24.2016.11.05.12.23.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Nov 2016 12:23:51 -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 , stable@vger.kernel.org Subject: [PATCH v2] mmc: mxs: Initialize the spinlock prior to using it Date: Sat, 5 Nov 2016 17:23:23 -0200 Message-Id: <1478373803-31815-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. Cc: Signed-off-by: Fabio Estevam Reviewed-by: Marek Vasut --- 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;