From patchwork Fri Dec 23 15:01:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 9487511 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 29A6F601D7 for ; Fri, 23 Dec 2016 15:03:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C8762018E for ; Fri, 23 Dec 2016 15:03:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F1EF23F88; Fri, 23 Dec 2016 15:03:03 +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=-4.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E8752018E for ; Fri, 23 Dec 2016 15:03:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cKRMy-0003mM-Hr; Fri, 23 Dec 2016 15:02:52 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cKRMf-0003iq-Hf; Fri, 23 Dec 2016 15:02:34 +0000 Received: from LT002.fritz.box ([84.119.32.78]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LqzIJ-1cpdZJ48It-00eZA3; Fri, 23 Dec 2016 16:01:23 +0100 From: Heinrich Schuchardt To: Ulf Hansson , Carlo Caione , Kevin Hilman Subject: [PATCH 1/1] MMC: meson: avoid possible NULL dereference Date: Fri, 23 Dec 2016 16:01:08 +0100 Message-Id: <20161223150108.9229-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.11.0 X-Provags-ID: V03:K0:47cAL6vvPvIZRn7aiQpJ05V/g3CaRd85t/dP/9e4u8cJv/gY8oD 55DNE+36oSZspn6vuZBT/UMq/MGxPRA/VLAor+OvPauBiyS8ui4U6fxfBS2JTcg3X1F1IBW f+SsMdir8NZlstpL2SHaviewD4q2Dnx11Udlv1b5anOpmvj7mCCr+6QhU+ZkL/UaTeLWViG sRoqBF7YLEOkVQ8MP1tyA== X-UI-Out-Filterresults: notjunk:1; V01:K0:SAcgSgIqKlQ=:yaP0Oh1gAzgM7k+/sA2Nt4 alG5/NP/fOs2nQ0ZKhdsIiLBbGuat+xBhYUi3tAJLNG5T6HBRV9EF1sC66r9dSssAmQ3efZmw 99RojE1nTLIQJcSh7hcIFrCKHo+ZaOWzEPykGyKy8HsWf2eI1TqGZ03+fpi8iNKtGvOm4ie2f aGRZ55PbTTdEoTNx2Oa1067H3iYChFfLAW4jPE+lCPYJwQEE4ny6BEixxtRQNt+qwR4eWYfws DkyqlT8nVShah49EICbuQDIiNQLpuohzdFsNQdGNYYxb6q2TM5SomXscpuFpQPu3V8XjTgnfT fOXty4STuMO788thZOHZhbggYsNJ/tKzwFD8tHzD1wvfsRBxMm+ojk64xr9rE+4PkBtO6c2a0 ZhxT9xMzeKL5Hb4Dku9Ewcjz3YF06n0mP75QR+ffTXeziXTk5UZRg8HNmA8eeYqlOFS9o/WU7 dVo74DVfD9G2ekTJvRKZ83n0NR7QTzMnCzwipLxAE327WVXrTi34V92wXBwq9lk5W/NUMLlCX jXaeOTyrXiOKG+B5t2z4jKn1/mEx9UgxLdutypTF7lH4wmcl4oEc9mwU0kDrAiKFoIgrEYzB4 XN0LPvfgZlwCoT1L99hnYEw3IJUt1cRzheZVUBGw94W7RCn3sQQrNDXG7Ra4GTDnKt1zrGRAb okjr+CMkyA2DK3aXvYIh/6t3xtXKk3anJi7nYRmDd19bUatrnKsJ+9UbKq1QN9iIba8COHGJd FI4DzDn94xRUyBx2R3WSsK8b2hgY1ZzEoV6NEDwlGWOsAt2NSUG2o1++guA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161223_070233_975329_02874305 X-CRM114-Status: UNSURE ( 8.00 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heinrich Schuchardt MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP No actual segmentation faults were observed but the coding is at least inconsistent. irqreturn_t meson_mmc_irq(): We should not dereference host before checking it. meson_mmc_irq_thread(): If cmd or mrq are NULL we should not dereference them after writing a warning. Fixes: 51c5d8447bd7 MMC: meson: initial support for GX platforms Signed-off-by: Heinrich Schuchardt Acked-by: Kevin Hilman --- drivers/mmc/host/meson-gx-mmc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index b352760c041e..09739352834c 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -578,13 +578,15 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) { struct meson_host *host = dev_id; struct mmc_request *mrq; - struct mmc_command *cmd = host->cmd; + struct mmc_command *cmd; u32 irq_en, status, raw_status; irqreturn_t ret = IRQ_HANDLED; if (WARN_ON(!host)) return IRQ_NONE; + cmd = host->cmd; + mrq = host->mrq; if (WARN_ON(!mrq)) @@ -670,10 +672,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) int ret = IRQ_HANDLED; if (WARN_ON(!mrq)) - ret = IRQ_NONE; + return IRQ_NONE; if (WARN_ON(!cmd)) - ret = IRQ_NONE; + return IRQ_NONE; data = cmd->data; if (data) {