From patchwork Wed Oct 30 11:43:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3114381 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 78F21BF924 for ; Wed, 30 Oct 2013 11:46:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CD162013A for ; Wed, 30 Oct 2013 11:46:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7381920148 for ; Wed, 30 Oct 2013 11:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754017Ab3J3LqA (ORCPT ); Wed, 30 Oct 2013 07:46:00 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:38542 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752374Ab3J3LpP (ORCPT ); Wed, 30 Oct 2013 07:45:15 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz1so819311pad.2 for ; Wed, 30 Oct 2013 04:45:15 -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=MeFe3x9bzZdkmv6qZA7+Hx5Mi1fZFiWfXamrpKdtmkI=; b=BYjvP1WlFEGp4ivr5PRlVeq921ihMqZr8N/zPQn6hFMP9Q5vPG3UB/89NJxyhB6x16 0zJgb2bpMMmuytYWP+14eAFMjJ5r+bFsm9l/j88DKGtzfeYpGgpNJRiGpiTi+8+m+OTu GLe+wqxLIhuJDvOHdMtdKH8JGvrrdTowHjCciwYbRNql+S+BS9zay9PiNGb9B2Yo1y1q S0+7HYHAdRbUN2Hqeyv1eqCZZi3HWf+jZKAcLuAy+C98L8XiEnlZ2ONInHKRIIhGaDNy qpJF3GgbWDVQ5cCNb0STaaa4ZCxsQl5TNYp14X2xGYabiITJVrGZ9GJrPk4YPjHF9VDB VycQ== X-Gm-Message-State: ALoCoQlwwAuNWmgDJqh16WVi5JqajEKnDNqp8oIJoYBtrVfx0I1f3AuuOSPjANmmKn1fuW4A6WnB X-Received: by 10.66.170.138 with SMTP id am10mr2577295pac.51.1383133514957; Wed, 30 Oct 2013 04:45:14 -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.12 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 04:45:14 -0700 (PDT) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, sachin.kamat@linaro.org Subject: [PATCH Resend 3/7] mmc: sdhci-spear: Fix NULL pointer dereference Date: Wed, 30 Oct 2013 17:13:46 +0530 Message-Id: <1383133430-22079-3-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 pdata could be NULL if cd_gpio = -1. Dereference pdata only if it is not NULL. Signed-off-by: Sachin Kamat Acked-by: Viresh Kumar --- drivers/mmc/host/sdhci-spear.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 9b6459d..af3fe87 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c @@ -84,14 +84,12 @@ static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pde /* If pdata is required */ if (cd_gpio != -1) { pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { + if (!pdata) dev_err(&pdev->dev, "DT: kzalloc failed\n"); - return ERR_PTR(-ENOMEM); - } + else + pdata->card_int_gpio = cd_gpio; } - pdata->card_int_gpio = cd_gpio; - return pdata; } #else