From patchwork Thu Sep 12 06:43:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 2876551 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 B04B3BF43F for ; Thu, 12 Sep 2013 07:01:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30D7320103 for ; Thu, 12 Sep 2013 07:01:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 816562021C for ; Thu, 12 Sep 2013 07:01:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753407Ab3ILHB2 (ORCPT ); Thu, 12 Sep 2013 03:01:28 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:37714 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393Ab3ILHB2 (ORCPT ); Thu, 12 Sep 2013 03:01:28 -0400 Received: by mail-pd0-f176.google.com with SMTP id q10so10266522pdj.21 for ; Thu, 12 Sep 2013 00:01:27 -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=rI2PkYCLrGXNYHrQ03pSE+zUHxuGNU6JxgAuM7TPyDQ=; b=NJNV1kwxGasOFE0j0Nd7xyx1UsryIdpnec39x+1jE8RHtKh4ygOeZRbAxNl89EKp7L YQj76g+Ap3g0Ya+WT6pZ1fU6tRa7zn/NEmVXqa/UmaMaa1lN3EDku+U3eBQyFu9NaP1E Ky/GkAMjAmyTaa8S9vTGuUIXUIfDMERIsaWQZ/yyaJ2HP1N+TkcuojP98NzuXqquawYQ WWEiJiwTp4sUaHmqwPskrS8XaAG44P2TXI6wWBm4kdNrCrNi81+1l7co/aNCaVJgoYbH btMfUZDb6MjySjc1O3YJO908B2LuzFbyC94LUTCIe2WZ1r3kZJXKVn3jhrXB+Ah35WXy s9/w== X-Gm-Message-State: ALoCoQlQ6uv7zqZYL0hDSg7NyerJmmbuzcVoWMRLODLJ0hMtKpidWRTWiviLKDofUGue+5FBNEaN X-Received: by 10.68.52.200 with SMTP id v8mr6138176pbo.48.1378969287731; Thu, 12 Sep 2013 00:01:27 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id py4sm2723139pbc.14.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Sep 2013 00:01:27 -0700 (PDT) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, spear-devel@list.st.com, sachin.kamat@linaro.org, Viresh Kumar Subject: [PATCH 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Date: Thu, 12 Sep 2013 12:13:20 +0530 Message-Id: <1378968200-16577-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 pdata could be NULL if cd_gpio = -1. Hence move the NULL check outside the if condition. Signed-off-by: Sachin Kamat Cc: Viresh Kumar --- Only compile tested. --- drivers/mmc/host/sdhci-spear.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 2dba9f8..4f3557a 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c @@ -82,12 +82,12 @@ static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pde cd_gpio = -1; /* If pdata is required */ - if (cd_gpio != -1) { + if (cd_gpio != -1) pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - dev_err(&pdev->dev, "DT: kzalloc failed\n"); - return ERR_PTR(-ENOMEM); - } + + if (!pdata) { + dev_err(&pdev->dev, "pdata is NULL\n"); + return ERR_PTR(-ENOMEM); } pdata->card_int_gpio = cd_gpio;