From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752594AbbL1KXd (ORCPT ); Mon, 28 Dec 2015 05:23:33 -0500 Received: from conuserg009.nifty.com ([202.248.44.35]:48101 "EHLO conuserg009-v.nifty.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752031AbbL1KXY (ORCPT ); Mon, 28 Dec 2015 05:23:24 -0500 X-Nifty-SrcIP: [153.142.97.90] From: Masahiro Yamada To: linux-clk@vger.kernel.org Cc: Masahiro Yamada , Stephen Boyd , Michael Turquette , linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2 14/16] clk: make sure parent is not NULL in clk_fetch_parent_index() Date: Mon, 28 Dec 2015 19:23:08 +0900 Message-Id: <1451298191-30815-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451298191-30815-1-git-send-email-yamada.masahiro@socionext.com> References: <1451298191-30815-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If parent is given with NULL, clk_fetch_parent_index() could return a positive index value. Currently, parent is checked by the callers of this function, but it would be safer to do it in this function. Signed-off-by: Masahiro Yamada --- Changes in v2: - Fix a bug. Return -EINVAL when parent _is_ NULL. drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index efd093a..151cbe8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1066,6 +1066,9 @@ static int clk_fetch_parent_index(struct clk_core *core, { int i; + if (!parent) + return -EINVAL; + /* * find index of new parent clock using cached parent ptrs, * or if not yet cached, use string name comparison and cache -- 1.9.1