From patchwork Tue Feb 25 09:48:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3714241 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 4BDFCBF13A for ; Tue, 25 Feb 2014 09:54:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A3372016C for ; Tue, 25 Feb 2014 09:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 715D72013D for ; Tue, 25 Feb 2014 09:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751106AbaBYJyN (ORCPT ); Tue, 25 Feb 2014 04:54:13 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:59504 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbaBYJyM (ORCPT ); Tue, 25 Feb 2014 04:54:12 -0500 Received: by mail-pd0-f171.google.com with SMTP id r10so2036868pdi.2 for ; Tue, 25 Feb 2014 01:54:12 -0800 (PST) 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:in-reply-to :references; bh=0O9Qx8ZSjLR5Ndn8f7KCZGhjQrDqdlfD+0m1W8Hzf4E=; b=BSuu86d07Drlm0AqSXQJnaNYU0syDWkGq8oPm4lFhu6Re1n+MWcu8Y0ScSWyEAnvvN M7RQhYwdMDOQkCoWGEwMF2oX+T4PyOjyHm2BQMkAwSTEqW0lSmT6HVYUBtt95iaCq/mJ t4CwKOmVo/OrhiPZguPvnrTYLNpsBHdRMiNY0TrlXt5Yg+C0jbQAyxKoRlJOn5yX50LI LRhI2SfdbqARgJEpM2WCRk4bHxkD1K2oRZbf9wkewe2uni2Dcsvwn12nXUn/ecgb6N5v uz+ZwkU+TygX/WDKR4QmK6AkYB1dbbUvO2HV0osS6fajmwJ0M/FEfoINQXRdTDJzfoj4 ERpQ== X-Gm-Message-State: ALoCoQmPycsnOzndZLhgNL+h2bQ5MoBYWJ9mT7KFJCN9V47sntsDd6XkDJ33FRCIOxFu3DQanMrh X-Received: by 10.66.176.143 with SMTP id ci15mr610929pac.35.1393322051576; Tue, 25 Feb 2014 01:54:11 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id qq5sm8804447pbb.24.2014.02.25.01.54.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 01:54:11 -0800 (PST) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, chris@printf.net, sachin.kamat@linaro.org Subject: [PATCH 02/10] mmc: wmt-sdmmc: Fix NULL pointer dereference Date: Tue, 25 Feb 2014 15:18:20 +0530 Message-Id: <1393321708-9719-2-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393321708-9719-1-git-send-email-sachin.kamat@linaro.org> References: <1393321708-9719-1-git-send-email-sachin.kamat@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 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 --- 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 e902ed7846b0..498d1f799085 100644 --- a/drivers/mmc/host/wmt-sdmmc.c +++ b/drivers/mmc/host/wmt-sdmmc.c @@ -757,7 +757,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; @@ -766,6 +766,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;