From patchwork Thu Oct 31 12:03:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3120321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5DE0B9F2B7 for ; Thu, 31 Oct 2013 12:04:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F17D203C4 for ; Thu, 31 Oct 2013 12:04:29 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1340E203B4 for ; Thu, 31 Oct 2013 12:04:28 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VbqzB-0003fo-5q; Thu, 31 Oct 2013 12:04:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vbqz8-0006sV-Rj; Thu, 31 Oct 2013 12:04:22 +0000 Received: from mail-bk0-x229.google.com ([2a00:1450:4008:c01::229]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vbqz6-0006s1-SU for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2013 12:04:21 +0000 Received: by mail-bk0-f41.google.com with SMTP id na10so1145950bkb.14 for ; Thu, 31 Oct 2013 05:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0YoYqu8ltW2Y3v+lqPNEYR9MJini8N1piQWdGg9icbw=; b=EjmA8GCTt0ekfiflb8OOFSUeGBr0RDw5ayytwaZcDxp9VAJht2V5jNOpdPJ/ly1TaW k+yUXrNMAN3vtnEf+tmrcqYEXKoPwTwOxQ1Q4KHNIUp7iXHvsA8qqs9DLBMSf0NCinl9 YM+ajA8WMMlGD9xtKzV47+9QCDBTm2jgLCaha9Fy/ZfwL6wKuTNHbpyjRE36XCZIiu1u dVtgcdWxurLrZwrcIg8Q9fiLvgshRMPIxMT3v7H8dxcIqXitemeH5ZbW2QBH6e7DEb9W fvbuzGfU451CytgGHhC3SzHw68lOQ62j0rudJImhff7yOg7Ly60YmzHMIpQWZNd/vAsU IHmQ== X-Received: by 10.204.176.66 with SMTP id bd2mr1320342bkb.39.1383221038081; Thu, 31 Oct 2013 05:03:58 -0700 (PDT) Received: from localhost (port-53007.pppoe.wtnet.de. [46.59.207.183]) by mx.google.com with ESMTPSA id pk7sm1986036bkb.2.2013.10.31.05.03.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Oct 2013 05:03:57 -0700 (PDT) From: Thierry Reding To: Mike Turquette Subject: [PATCH] clk: Do not dereference potential NULL pointer Date: Thu, 31 Oct 2013 13:03:56 +0100 Message-Id: <1383221036-26890-1-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131031_080421_054011_6E7DC3DA X-CRM114-Status: GOOD ( 10.54 ) X-Spam-Score: -2.0 (--) Cc: Stephen Boyd , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 A NULL pointer may be passed to _clk_register() for the dev parameter (via clk_register()). Make sure not to dereference it before checking that it's valid. Signed-off-by: Thierry Reding Acked-by: Stephen Boyd --- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b68a999..c0b52e3 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1976,7 +1976,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk) hw->regmap = hw->init->regmap; else if (dev && dev_get_regmap(dev, NULL)) hw->regmap = dev_get_regmap(dev, NULL); - else if (dev->parent) + else if (dev && dev->parent) hw->regmap = dev_get_regmap(dev->parent, NULL); /* allocate local copy in case parent_names is __initdata */