From patchwork Wed Jan 15 05:55:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3490141 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 3B749C02DC for ; Wed, 15 Jan 2014 05:59:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D4452017D for ; Wed, 15 Jan 2014 05:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A321D20179 for ; Wed, 15 Jan 2014 05:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751259AbaAOF7b (ORCPT ); Wed, 15 Jan 2014 00:59:31 -0500 Received: from mail-pd0-f181.google.com ([209.85.192.181]:51372 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbaAOF7a (ORCPT ); Wed, 15 Jan 2014 00:59:30 -0500 Received: by mail-pd0-f181.google.com with SMTP id p10so667803pdj.12 for ; Tue, 14 Jan 2014 21:59:30 -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=++v5OOb7sOcRtvrsT68aeutQZpcDuR4c5Y5R9ppTb1k=; b=VQEI38nnoh1eHCIBcKYO3OMPEs+BVUBqcGb1VsKWfGxXwS+g/bxRgyRI+xYuHmd4gs fU+I/5CRzW65qEHUR8KMLe1OV/1/MiaiOwqQlyAt/KDFzJSdKmfALq9WaP7/AVJoC87j /ZTpAC+BtIPi3US3JJzIRqMimCxLSKBVmEy+fXDtqwNE0iVQUHlS5k23C+eQziY2IF0b fUdeNuD+rPtm1JK8T7+Wmf+HXVRqlabhaRBmePUlm0yrUeExU8dTEBveXN/8ptKuouyp XuRzbF9A4Zp1pNsLDzSnCljxQYoMHze+JTIcf7UknuZ2kTMc2Pus1MUBDBFKDpAoHCvY 9suw== X-Gm-Message-State: ALoCoQkUR9XEQPhyMul/zdv4GZG9saY6I06m3ITd61itczhxIWLeYO60Bt701XjMhFYuXqn5vxyJ X-Received: by 10.66.51.137 with SMTP id k9mr384706pao.11.1389765570129; Tue, 14 Jan 2014 21:59:30 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id kk1sm5423001pbd.22.2014.01.14.21.59.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 21:59:29 -0800 (PST) From: Sachin Kamat To: linux-mmc@vger.kernel.org Cc: chris@printf.net, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 3/9] mmc: sdhci-spear: Fix NULL pointer dereference Date: Wed, 15 Jan 2014 11:25:07 +0530 Message-Id: <1389765313-16744-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389765313-16744-1-git-send-email-sachin.kamat@linaro.org> References: <1389765313-16744-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.2 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 2dba9f8d1760..76ddd89a688e 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