From patchwork Fri May 30 10:05:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 31165 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5CD820671 for ; Fri, 30 May 2014 10:08:04 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id a108sf4199916qge.6 for ; Fri, 30 May 2014 03:08:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=EFMNRIbkVzpKoyF3QkTG/FpvxckYe2RP+BKF/VThpxE=; b=Lj2ddxspXTP24euQbGPobwpV2ORjx3EZxkE9YhzBxzutIsu0W7obp85TgP6vCj44Jr vxbVp/D4EMucIBOyw9Ycv3moUeoNLWH7YuagPrtKwjlJRHj0DnfaKZKuGnEiXzk5e66y 4VYexjNaTw7sQ+1mIg3OW7vTjtLHSbql0iBJlrzYSx2xIPEulestlahs8tf7v7fYdub0 QT82IPRVB/JlZbIFC08fOJiC2PBP+67Ui/TLd2Ao26AKYbJTRBstbEMVkqMK5fgvNLcw AUF7TEGxcGlqZp8As9zHiX8t2k/XJmJhv1myIly6XhbGdxFOuNlVOrxAXec3o5JRcONm V6lQ== X-Gm-Message-State: ALoCoQlxtonGsx+V15s0HHsQxdxIdwv/1rkXRNxpOvGPLUu1uIM/11IKf2U6D0+rPrluvt3/bijZ X-Received: by 10.236.178.98 with SMTP id e62mr4936391yhm.50.1401444484137; Fri, 30 May 2014 03:08:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.201 with SMTP id k67ls983204qge.22.gmail; Fri, 30 May 2014 03:08:04 -0700 (PDT) X-Received: by 10.220.133.197 with SMTP id g5mr12759126vct.20.1401444484025; Fri, 30 May 2014 03:08:04 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id xe6si2642443vcb.28.2014.05.30.03.08.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 03:08:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so1837298veb.35 for ; Fri, 30 May 2014 03:08:03 -0700 (PDT) X-Received: by 10.53.13.35 with SMTP id ev3mr10490197vdd.1.1401444483936; Fri, 30 May 2014 03:08:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp99016vcb; Fri, 30 May 2014 03:08:03 -0700 (PDT) X-Received: by 10.68.136.226 with SMTP id qd2mr17080235pbb.72.1401444483099; Fri, 30 May 2014 03:08:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id un1si4932274pac.13.2014.05.30.03.08.02; Fri, 30 May 2014 03:08:02 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933051AbaE3KHz (ORCPT + 28 others); Fri, 30 May 2014 06:07:55 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:43352 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932997AbaE3KHx (ORCPT ); Fri, 30 May 2014 06:07:53 -0400 Received: by mail-pa0-f41.google.com with SMTP id kx10so1563118pab.0 for ; Fri, 30 May 2014 03:07:53 -0700 (PDT) X-Received: by 10.68.250.3 with SMTP id yy3mr17247921pbc.56.1401444472900; Fri, 30 May 2014 03:07:52 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id fv2sm5605832pbd.11.2014.05.30.03.07.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 03:07:52 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, sameo@linux.intel.com, sachin.kamat@linaro.org Subject: [PATCH 1/1] mfd: asic3: Fix potential null pointer dereference Date: Fri, 30 May 2014 15:35:28 +0530 Message-Id: <1401444328-10746-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We previously assumed 'mem_sdio' could be null but it is dereferenced in ioremap(). Add a check to avoid a potential null pointer dereference error. Signed-off-by: Sachin Kamat --- drivers/mfd/asic3.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 9f6294f2a070..9fc4186d4132 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -899,13 +899,15 @@ static int __init asic3_mfd_probe(struct platform_device *pdev, ds1wm_resources[0].end >>= asic->bus_shift; /* MMC */ - asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) + + if (mem_sdio) { + asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) + mem_sdio->start, ASIC3_SD_CONFIG_SIZE >> asic->bus_shift); - if (!asic->tmio_cnf) { - ret = -ENOMEM; - dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n"); - goto out; + if (!asic->tmio_cnf) { + ret = -ENOMEM; + dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n"); + goto out; + } } asic3_mmc_resources[0].start >>= asic->bus_shift; asic3_mmc_resources[0].end >>= asic->bus_shift;