From patchwork Tue Jun 10 10:00:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 31620 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 262D32054B for ; Tue, 10 Jun 2014 10:03:36 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id uo5sf12934237pbc.4 for ; Tue, 10 Jun 2014 03:03:35 -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=PQuFMAvF1QD3idBFinYVNmekZFW2NJhg3JE0TFPXUDObkvSxjzrksM39aaTd7Lf0EZ fl2kehZaxKF48GSIhrk0apZu7hzXlExFnCk4Y+C5JF5UCgBSkOd5HL6xFcLf97PBY5/C 77Z10zSEd3DThfWJMaYX8XIGCkDpdpdQwRPRxJCNzBqaZiQSgNJnDGzSfmU+4c5Ubf3w RJzMZfZgtZzQUyGtykY8z7FPglqtTlqSGpHoCsAaA5MRdhtbZhRzGQf9wO4EYl4wIJkQ ybZ/MHY8cmPYqMSdVKcx2s0evHaM99vFEk06YcSeR0Du1vyVhv7GLKym6i13ZARFHqt4 IOHQ== X-Gm-Message-State: ALoCoQlPn78pi5ygSZ682Jtsc6Am41U+oKk63QoRGgNODwjvH7M/JnWObKuF7MzA6BYmwTqw6hz9 X-Received: by 10.66.122.137 with SMTP id ls9mr2020356pab.17.1402394615454; Tue, 10 Jun 2014 03:03:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls1962186qge.74.gmail; Tue, 10 Jun 2014 03:03:35 -0700 (PDT) X-Received: by 10.52.138.232 with SMTP id qt8mr26307153vdb.44.1402394615202; Tue, 10 Jun 2014 03:03:35 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id xy4si11644745vcb.35.2014.06.10.03.03.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 03:03:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id sa20so7918835veb.13 for ; Tue, 10 Jun 2014 03:03:35 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr31410644vcx.7.1402394615119; Tue, 10 Jun 2014 03:03:35 -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.221.54.6 with SMTP id vs6csp212880vcb; Tue, 10 Jun 2014 03:03:34 -0700 (PDT) X-Received: by 10.66.65.204 with SMTP id z12mr4222054pas.97.1402394614119; Tue, 10 Jun 2014 03:03:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pn2si33840528pbb.70.2014.06.10.03.03.33; Tue, 10 Jun 2014 03:03:33 -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 S1752063AbaFJKDZ (ORCPT + 27 others); Tue, 10 Jun 2014 06:03:25 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:56054 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750717AbaFJKDY (ORCPT ); Tue, 10 Jun 2014 06:03:24 -0400 Received: by mail-pa0-f50.google.com with SMTP id fb1so544119pad.9 for ; Tue, 10 Jun 2014 03:03:23 -0700 (PDT) X-Received: by 10.66.255.67 with SMTP id ao3mr4289583pad.25.1402394603548; Tue, 10 Jun 2014 03:03:23 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id pr4sm68588183pbb.53.2014.06.10.03.03.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 03:03:22 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, sameo@linux.intel.com, spk.linux@gmail.com Subject: [PATCH Resend] mfd: asic3: Fix potential null pointer dereference Date: Tue, 10 Jun 2014 15:30:34 +0530 Message-Id: <1402394434-903-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.182 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;