From patchwork Wed Oct 30 11:43:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3114391 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 06DB49F43F for ; Wed, 30 Oct 2013 11:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73D2320155 for ; Wed, 30 Oct 2013 11:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E5472012E for ; Wed, 30 Oct 2013 11:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770Ab3J3LpP (ORCPT ); Wed, 30 Oct 2013 07:45:15 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]:54748 "EHLO mail-pb0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752727Ab3J3LpN (ORCPT ); Wed, 30 Oct 2013 07:45:13 -0400 Received: by mail-pb0-f51.google.com with SMTP id wz7so1254943pbc.38 for ; Wed, 30 Oct 2013 04:45:12 -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:in-reply-to :references; bh=gqhpMMF5MPUiOcBjze2wonBe1LnznGSJGGx17pW8TR8=; b=JlnNKJVWGi7vsfHshVp5p3PUIAOgJTNeWCs/S0+Q3IZBZCV20XQ0LdmPC8JD7zlJXe ugXuS7n7TvOBXDgyiRZuhkqZX1CZ5vozczu/K07EYmTzxR55evr7YqL0TJlxU1w3q/GV Hsg6iaDOdciQ7JkhQOjs4EhOR7i38RaOmPZevMRX867MHq+6mm05xEhU2FRnX+ZZXZVE l71R0AoTjbvcUhqPRyiBf594xJjAQIfy6+b9XPmBeLxg/JTLYZtBUcwnQpz1nHph9nKv TCj21mJ1WMJmpHrFn5J7tIK9/J5McOlCa7y+U1FvEwnrDaPbVbUfmSHV5U59S1XCZTN9 7d1A== X-Gm-Message-State: ALoCoQn1FXzAsPU/s5aIE04eVoKNCUY+8gVnViLz9fWEO2KhCrv0vQP3IUk/8QaxHpS9el04dfrX X-Received: by 10.68.197.200 with SMTP id iw8mr1278028pbc.197.1383133512730; Wed, 30 Oct 2013 04:45:12 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id xn12sm4294655pac.12.2013.10.30.04.45.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 04:45:12 -0700 (PDT) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, sachin.kamat@linaro.org Subject: [PATCH Resend 2/7] mmc: wmt-sdmmc: Fix NULL pointer dereference Date: Wed, 30 Oct 2013 17:13:45 +0530 Message-Id: <1383133430-22079-2-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1383133430-22079-1-git-send-email-sachin.kamat@linaro.org> References: <1383133430-22079-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=-7.4 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 e902ed7..498d1f7 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;