From patchwork Tue Feb 12 04:57:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2127201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 7FF36DFB7B for ; Tue, 12 Feb 2013 05:06:07 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U5821-0007Tx-Bg; Tue, 12 Feb 2013 05:03:49 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U580r-00077d-MU for linux-arm-kernel@lists.infradead.org; Tue, 12 Feb 2013 05:02:42 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r1C52Mcs014358; Mon, 11 Feb 2013 23:02:22 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r1C52MSo012935; Mon, 11 Feb 2013 23:02:22 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Mon, 11 Feb 2013 23:02:22 -0600 Received: from localhost (irmo.am.dhcp.ti.com [128.247.74.241]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r1C52MvX009651; Mon, 11 Feb 2013 23:02:22 -0600 From: Suman Anna To: Greg Kroah-Hartman Subject: [PATCH v2 13/13] mailbox: call request_irq after mbox queues are allocated Date: Mon, 11 Feb 2013 22:57:12 -0600 Message-ID: <1360645032-9668-14-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360645032-9668-1-git-send-email-s-anna@ti.com> References: <1360645032-9668-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130212_000237_889276_F9F5C39E X-CRM114-Status: GOOD ( 11.10 ) X-Spam-Score: -4.6 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.40 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ohad Ben-Cohen , Paul Walmsley , linux-omap@vger.kernel.org, Russell King , Benoit Cousson , Arnd Bergmann , Janusz Krzysztofik , Tony Lindgren , Linus Walleij , Mark Brown , Suman Anna , linux-kernel@vger.kernel.org, Felipe Contreras , Dom Cobley , Wim Van Sebroeck , Fernando Guzman Lugo , Omar Ramirez Luna , Tejun Heo , Omar Ramirez Luna , Loic Pallardy , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The mailbox startup code is enabling the interrupt even before any of the associated mailbox queues are allocated. Any pending received mailbox message could cause a kernel panic as soon as the interrupt is enabled due to the dereferencing of non-existing mailbox queues within the ISR. Signed-off-by: Fernando Guzman Lugo Signed-off-by: Suman Anna --- drivers/mailbox/mailbox.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index c38241a..5fea5c2 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -377,14 +377,6 @@ static int mailbox_startup(struct mailbox *mbox) } if (!mbox->use_count++) { - ret = request_irq(mbox->irq, mbox_interrupt, - IRQF_SHARED | IRQF_NO_SUSPEND, - mbox->name, mbox); - if (unlikely(ret)) { - pr_err("failed to register mailbox interrupt:%d\n", - ret); - goto fail_request_irq; - } mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet); if (!mq) { ret = -ENOMEM; @@ -399,17 +391,25 @@ static int mailbox_startup(struct mailbox *mbox) } mbox->rxq = mq; mq->mbox = mbox; + ret = request_irq(mbox->irq, mbox_interrupt, + IRQF_SHARED | IRQF_NO_SUSPEND, + mbox->name, mbox); + if (unlikely(ret)) { + pr_err("failed to register mailbox interrupt:%d\n", + ret); + goto fail_request_irq; + } mailbox_enable_irq(mbox, IRQ_RX); } mutex_unlock(&mbox_configured_lock); return 0; +fail_request_irq: + mbox_queue_free(mbox->rxq); fail_alloc_rxq: mbox_queue_free(mbox->txq); fail_alloc_txq: - free_irq(mbox->irq, mbox); -fail_request_irq: if (mbox->ops->shutdown) mbox->ops->shutdown(mbox); mbox->use_count--;