From patchwork Thu Sep 12 08:21:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 2876971 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 265EDBF43F for ; Thu, 12 Sep 2013 08:39:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF585202B4 for ; Thu, 12 Sep 2013 08:39:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8F2B202D9 for ; Thu, 12 Sep 2013 08:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751939Ab3ILIja (ORCPT ); Thu, 12 Sep 2013 04:39:30 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:63537 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810Ab3ILIj3 (ORCPT ); Thu, 12 Sep 2013 04:39:29 -0400 Received: by mail-pb0-f42.google.com with SMTP id un15so10273852pbc.29 for ; Thu, 12 Sep 2013 01:39:28 -0700 (PDT) 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=6U/dEdav/8zc1TPkvRqtG8X2iURLAch3RPTINTK065c=; b=HqHGrL83dBQZI0Kf6N+oljpg/A7C4Dob1QX0OpuYk7ZpfViVJCnxDqQxVWBAY995RE QksVwerDi2sX42pcs6y8Cd7xSnpwApKGEb+CwMjGzuz4cJoXVySDSvTk+YkGZ6YLS169 8aVnlLDBgEZZUDpquDLSgLkwfPxWALP2x1e39nq/uYsP5CID1ip1bva0OWOVscF+0zIp 2k+hqaRNbRNH4JxUsKIFFcPnfypyI4TnynQHNH9BE/Ja8bO2zFyncNGMJRA9/Kp6GWlU EmveXIl5i41EMlyJER99D2mtHnEA8visUOm2vd4YJWtfw9tKHMXMn2tj78teTMj5+wxr bMgQ== X-Gm-Message-State: ALoCoQlkQCPFQr4RV+OBmu0the6RBgPGU19IZM9fzRVnkse4nhIWxlTsVBEk3pt73nXWP/Gt2Sue X-Received: by 10.68.229.2 with SMTP id sm2mr6383027pbc.68.1378975168369; Thu, 12 Sep 2013 01:39:28 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id zq10sm9190650pab.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Sep 2013 01:39:27 -0700 (PDT) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, linux@prisktech.co.nz, sachin.kamat@linaro.org Subject: [PATCH 1/1] mmc: wmt-sdmmc: Fix NULL pointer dereference Date: Thu, 12 Sep 2013 13:51:18 +0530 Message-Id: <1378974078-15416-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'of_id' is dereferenced before NULL pointer check. Move it to after the check. Signed-off-by: Sachin Kamat Acked-by: Tony Prisk --- Compile tested. --- drivers/mmc/host/wmt-sdmmc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c index 34231d5..3523a72 100644 --- a/drivers/mmc/host/wmt-sdmmc.c +++ b/drivers/mmc/host/wmt-sdmmc.c @@ -771,7 +771,7 @@ static int wmt_mci_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(wmt_mci_dt_ids, &pdev->dev); - const struct wmt_mci_caps *wmt_caps = of_id->data; + const struct wmt_mci_caps *wmt_caps; int ret; int regular_irq, dma_irq; @@ -780,6 +780,8 @@ static int wmt_mci_probe(struct platform_device *pdev) return -EFAULT; } + wmt_caps = of_id->data; + if (!np) { dev_err(&pdev->dev, "Missing SDMMC description in devicetree\n"); return -EFAULT;