From: Tony Lindgren <tony@atomide.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Tero Kristo <t-kristo@ti.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>, Keerthy <j-keerthy@ti.com>,
linux-omap@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] clk: ti: divider: try to fix ti_clk_register_divider
Date: Wed, 19 Apr 2017 13:05:06 -0700 [thread overview]
Message-ID: <20170419200506.GB19537@atomide.com> (raw)
In-Reply-To: <20170419174507.4055014-1-arnd@arndb.de>
* Arnd Bergmann <arnd@arndb.de> [170419 10:48]:
> The newly introduced function is entirely bogus as I found when looking
> at this warning:
>
> drivers/clk/ti/divider.c: In function 'ti_clk_register_divider':
> drivers/clk/ti/divider.c:460:8: error: 'reg' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> Treating a 'u32' variable as a structure leads to a stack overflow here,
> and the register address we pass down is never initialized.
>
> As the code in its original form makes no sense, I can only guess what
> the intention was, and change it to take the address from div->reg.ptr
> instead.
>
> Fixes: d96f774b2538 ("clk: ti: divider: add support for legacy divider init")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/clk/ti/divider.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
> index d6dcb283b72b..a6d3bbfbbd31 100644
> --- a/drivers/clk/ti/divider.c
> +++ b/drivers/clk/ti/divider.c
> @@ -428,22 +428,17 @@ struct clk_hw *ti_clk_build_component_div(struct ti_clk_divider *setup)
>
> struct clk *ti_clk_register_divider(struct ti_clk *setup)
> {
> - struct ti_clk_divider *div;
> - struct clk_omap_reg *reg_setup;
> - u32 reg;
> + struct ti_clk_divider *div = setup->data;
> + struct clk_omap_reg reg_setup = {
> + .index = div->module,
> + .offset = div->reg,
> + };
> u8 width;
> u32 flags = 0;
> u8 div_flags = 0;
> const struct clk_div_table *table;
> struct clk *clk;
>
> - div = setup->data;
> -
> - reg_setup = (struct clk_omap_reg *)®
> -
> - reg_setup->index = div->module;
> - reg_setup->offset = div->reg;
> -
> if (div->flags & CLKF_INDEX_STARTS_AT_ONE)
> div_flags |= CLK_DIVIDER_ONE_BASED;
>
> @@ -458,7 +453,7 @@ struct clk *ti_clk_register_divider(struct ti_clk *setup)
> return (struct clk *)table;
>
> clk = _register_divider(NULL, setup->name, div->parent,
> - flags, (void __iomem *)reg, div->bit_shift,
> + flags, ®_setup, div->bit_shift,
> width, div_flags, table);
>
> if (IS_ERR(clk))
Yeah seems broken. I wonder if this explains some of the omapdrm
issues we're seeing in next?
Regards,
Tony
next prev parent reply other threads:[~2017-04-19 20:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 17:44 [PATCH 1/2] clk: ti: divider: try to fix ti_clk_register_divider Arnd Bergmann
2017-04-19 17:44 ` [PATCH 2/2] clk: ti: fix building without legacy omap3 Arnd Bergmann
2017-04-20 15:25 ` Tero Kristo
2017-04-22 2:23 ` Stephen Boyd
2017-04-19 20:05 ` Tony Lindgren [this message]
2017-04-20 15:46 ` [PATCH 1/2] clk: ti: divider: try to fix ti_clk_register_divider Tero Kristo
2017-04-22 1:58 ` Stephen Boyd
2017-04-22 12:08 ` Arnd Bergmann
2017-04-28 18:36 ` Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170419200506.GB19537@atomide.com \
--to=tony@atomide.com \
--cc=arnd@arndb.de \
--cc=j-keerthy@ti.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@codeaurora.org \
--cc=t-kristo@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).