From patchwork Thu Oct 27 18:57:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9400211 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 9980060231 for ; Thu, 27 Oct 2016 18:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 814C02A37A for ; Thu, 27 Oct 2016 18:58:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75F012A380; Thu, 27 Oct 2016 18:58:08 +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 686452A37A for ; Thu, 27 Oct 2016 18:58:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936496AbcJ0S6E (ORCPT ); Thu, 27 Oct 2016 14:58:04 -0400 Received: from mail-vk0-f67.google.com ([209.85.213.67]:34082 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938571AbcJ0S6C (ORCPT ); Thu, 27 Oct 2016 14:58:02 -0400 Received: by mail-vk0-f67.google.com with SMTP id c126so589580vkd.1 for ; Thu, 27 Oct 2016 11:58:01 -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=BEG0pJvNsejs67RrRZli2QsAmw/YXrCiicHTRH+vClw=; b=S204aqypHWa2HGmrKPTkCJGPWm0HSgVEZfYRhPxc1fjX5D1d6exSxMfs5FjO3p1KfJ 6L1Jdk3EqqkwhpPVPtFRjIOq7WV/lQdBzTdwehKMZ0aB7ofkYmVimA7RQ9CYxsQjHC2y Hs/hvqp5hBA9WD88R0peg5Ar8thzkU0hobfG8Ut+Fn8eUtym77AzeIoXUuw4fV2CPByU ZqNNUly9aWYCdRwaB/zXpExYvu7yzFeld57csvQrNeKPHTLxy9skIMMpuj6myM244D9f k6YUu2XuxnDvqaIKug9xtJfjBJBET0BUBpiJPkUWJ2AxZ+bc+gagoTfyTvYg4UHtOhE5 Ce1Q== 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=BEG0pJvNsejs67RrRZli2QsAmw/YXrCiicHTRH+vClw=; b=ipoy44h5+j6hpMqxUPNLzp9hzbhjt8VjbNMTE4GgV2oS9GdbEvz7+h8qVKn2FIYqD7 J4L5O+xqWjojjOHmsMxIHtjwKjsshPbACZwvVHC/LXOiH41bPY0ao0Cwy4W0+NCPAT5B seQdHXahcHOYj5a/bz05EO4EQcZktbm93Eb1P3usAG1iXfl36Y6XsZJYZbAUDv2zd4xV 1Lr9GPV1jz/Yz0WNk8db4CAi0VpyZno27iv6xiWm1G6UiCyjhJ0slyKiE+k8YC/9ZbNH Gvl0tI+UjAzA/r1mAM8fDvIJO4Hc0NRJhy3hXC0Y9ls7OKQGxR1O+Y5FSURYxfVsra4b 107w== X-Gm-Message-State: ABUngveHhuk2jAqYJ7JmcnZLeRQ5Ow/qm+amg9FvjBBRSpaaDYxFwWvP9PzVZLr3wE96XQ== X-Received: by 10.31.154.145 with SMTP id c139mr8432641vke.35.1477594681022; Thu, 27 Oct 2016 11:58:01 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:482:75c:4d59:e1a4:67ce:bc9c]) by smtp.gmail.com with ESMTPSA id z5sm2085040vke.18.2016.10.27.11.57.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Oct 2016 11:58:00 -0700 (PDT) From: Fabio Estevam To: ulf.hansson@linaro.org Cc: kernel@pengutronix.de, linux-mmc@vger.kernel.org, stefan.wahren@i2se.com, marex@denx.de, Fabio Estevam Subject: [PATCH 1/2] mmc: mxs: Initialize the spinlock prior to using it Date: Thu, 27 Oct 2016 16:57:51 -0200 Message-Id: <1477594672-31611-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. Signed-off-by: Fabio Estevam Reviewed-by: Marek Vasut --- 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;