From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752948AbcBBCj1 (ORCPT ); Mon, 1 Feb 2016 21:39:27 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:44840 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbcBBCjY (ORCPT ); Mon, 1 Feb 2016 21:39:24 -0500 Date: Mon, 1 Feb 2016 18:39:22 -0800 From: Stephen Boyd To: Masahiro Yamada Cc: linux-clk@vger.kernel.org, Michael Turquette , Linux Kernel Mailing List Subject: Re: [RESEND PATCH v2 10/16] clk: move checking .git_parent to __clk_core_init() Message-ID: <20160202023922.GL4848@codeaurora.org> References: <1451298191-30815-1-git-send-email-yamada.masahiro@socionext.com> <1451298191-30815-11-git-send-email-yamada.masahiro@socionext.com> <20160202005051.GO4848@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02, Masahiro Yamada wrote: > 2016-02-02 9:50 GMT+09:00 Stephen Boyd : > > On 12/28, Masahiro Yamada wrote: > >> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > >> index e6e10f5..4ad0a36 100644 > >> --- a/drivers/clk/clk.c > >> +++ b/drivers/clk/clk.c > >> @@ -1677,13 +1677,6 @@ static struct clk_core *__clk_init_parent(struct clk_core *core) > >> goto out; > >> } > >> > >> - if (!core->ops->get_parent) { > >> - WARN(!core->ops->get_parent, > >> - "%s: multi-parent clocks must implement .get_parent\n", > >> - __func__); > >> - goto out; > >> - } > >> - > >> /* > >> * Do our best to cache parent clocks in core->parents. This prevents > >> * unnecessary and expensive lookups. We don't set core->parent here; > >> @@ -2315,6 +2308,11 @@ static int __clk_core_init(struct clk_core *core) > >> goto out; > >> } > >> > >> + if (core->num_parents > 1 && !core->ops->get_parent) { > >> + pr_err("%s: %s must implement .get_parent as it has multi parents\n", > >> + __func__, core->name); > >> + } > >> + > > > > This would seem to allow a case where we may deref a null > > get_parent op if it isn't set and we call __clk_init_parent(). > > The next patch removes that case by restructuring > > __clk_init_parent(), so we should just combine these two patches > > together and that theoretical problem goes away. > > > > I think the case never happens. > > __clk_init_parent() is a static function that is only called from > __clk_core_init(). > So, the null pointer for .get_parent() has been already checked before > __clk_init_parent(). > Right, this patch moves the check to __clk_core_init(), and it will print an error and then keep going (because we lost the goto out part). Once we keep going in __clk_core_init() we'll call __clk_init_parent() and NULL pointer deref. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project