From patchwork Thu Dec 19 08:43:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3375711 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 E9F27C0D4A for ; Thu, 19 Dec 2013 08:46:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA7C32060E for ; Thu, 19 Dec 2013 08:46:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7C862061D for ; Thu, 19 Dec 2013 08:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845Ab3LSIq5 (ORCPT ); Thu, 19 Dec 2013 03:46:57 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:50373 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751813Ab3LSIq4 (ORCPT ); Thu, 19 Dec 2013 03:46:56 -0500 Received: by mail-pb0-f53.google.com with SMTP id ma3so857673pbc.40 for ; Thu, 19 Dec 2013 00:46:56 -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=Hohdqnz6R/ojAq4vRoKis9GhnH23hUCUuaZGjpTi8lN2OcqBo0e8JczCePnyQQACqj bZuqkHSG/v0bdTF5WIjBB/7T37GacZHp3PZvG96bYwxFMSM0gQ2Ibko/6ic5B3RQH+oW 8536yzSujrtslgP5a4GTgazW4ymPv/QIsk+5P/HvW94Vl135fJjrdgZtZLvH6GlJN6IF 3S4h4ihOFqQ/zCfJ5w3fLORyDR3uCYwByXPp84GsW8Htu1Da3qeo8/fqd81VvG1PIG1j 7v0QZm8CBJRAOzOSL5YG0f/o/wgYp+GlBiJgqtI3Cd77ti+L/ZD/+JtpH7BKu33BDPvI lDTA== X-Gm-Message-State: ALoCoQnF2EOc7ndE2iP31mbB1wUuZqZGpoe018xnGxgyhzu+IfCp7v/wfHOr/xi8zMCiumTLuv+g X-Received: by 10.66.142.233 with SMTP id rz9mr248652pab.71.1387442816335; Thu, 19 Dec 2013 00:46:56 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id oc9sm5520341pbb.10.2013.12.19.00.46.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 00:46:55 -0800 (PST) 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: Thu, 19 Dec 2013 14:13:30 +0530 Message-Id: <1387442614-4193-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387442614-4193-1-git-send-email-sachin.kamat@linaro.org> References: <1387442614-4193-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 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