From patchwork Thu Sep 12 09:04:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 2877171 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 B2737BF43F for ; Thu, 12 Sep 2013 09:22:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BEA52021A for ; Thu, 12 Sep 2013 09:22:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32D0E202EC for ; Thu, 12 Sep 2013 09:22:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756884Ab3ILJWM (ORCPT ); Thu, 12 Sep 2013 05:22:12 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:60088 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300Ab3ILJWK (ORCPT ); Thu, 12 Sep 2013 05:22:10 -0400 Received: by mail-pb0-f52.google.com with SMTP id wz12so10308982pbc.11 for ; Thu, 12 Sep 2013 02:22:09 -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=jObbgjeR6pwtM4qvKL8mcNYvmsCjCZFWg7y+gTBTRPM=; b=VqBUCp3SXmYtVl1QQIzIIDR3sqbapfV9YJUn8Iy/N14i8dVNNmDSImt6FPUfnv/JGJ u89FFku+49DixDKAYCK3YbQVHov1izRWeZ0N0h9oZwQhaTCS1kZIz3dze7/TfihrIFPn VeJccBA5epRF+uJfp5Ualtp3Jt/5FJOVvbDHlZOLP35RtdiLfYULT3dqCr6RqkOYIk7H 8LzJEK0D+OyUoZq9/FHuJkIzJii5xi8GcKjqlzJXQfRfxHqGkBQPJzYbtqHoalI7KXbM KdNoXCTEQ4jqmTs24mml6nQqeJ2P2vzWBlm4hPRmlnizqhRdxybw5wQ+DmYFG14qtCuP I0IA== X-Gm-Message-State: ALoCoQkCm8hXAIg+bQvXBJ+vSxGuqhC/Oqn2cer9ThEeV8xGknCxT3WbvcCJzvIMLakyewy1iZZL X-Received: by 10.66.170.168 with SMTP id an8mr8559962pac.58.1378977729782; Thu, 12 Sep 2013 02:22:09 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id m4sm1021120pbg.38.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Sep 2013 02:22:09 -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 v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Date: Thu, 12 Sep 2013 14:34:03 +0530 Message-Id: <1378976643-26717-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. Dereference pdata only if it is not NULL. Signed-off-by: Sachin Kamat Cc: Viresh Kumar Acked-by: Viresh Kumar --- Compile tested. Changes since v1: * Moved the pdata assignment inside if condition. --- 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 2dba9f8..76ddd89 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