Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968668AbdDSRpW (ORCPT ); Wed, 19 Apr 2017 13:45:22 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:57468 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935019AbdDSRpS (ORCPT ); Wed, 19 Apr 2017 13:45:18 -0400 From: Arnd Bergmann To: Tero Kristo , Michael Turquette , Stephen Boyd Cc: Arnd Bergmann , Tony Lindgren , Keerthy , linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] clk: ti: divider: try to fix ti_clk_register_divider Date: Wed, 19 Apr 2017 19:44:55 +0200 Message-Id: <20170419174507.4055014-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:tFpQ5YJn5guQh3OOi40AZlWPV63UuEbOsIddBq7xUh7Yf+iNuQ1 4QxVOp8/9dRIFbrjNdcrcg+FJPj0TeGaZBPkx5AFkMXdixsEboCqevHn68gYbMqofaq74zl cNyzjqNMiS+A+38d2Gg1dHxCNaF6F9LXmxJzkNan6cMRV5o/q6eqwGNt7c3A12DRrsNfLeG 1VOaL1JUd9kqfNgHGuvqg== X-UI-Out-Filterresults: notjunk:1;V01:K0:VcY67dysonE=:HcTXQOzHCDch64dtNbPY5+ 0d3acr2aw/pn6aM9+d5xGvHdg5Rkun2mTRbiFE1Zz1Y201P6OyKirltAdNWIs9+5p3l2b/V9a C2HZno/Lqu0RwcAT5kZNSKdcDCGsMaTI41v3BsNzTokJi4dRGiYbCBazLzGS8roqeqjKPTEok mUGtfR6kmDR9jEm2+wXsITQ9j6STuq4IQL5UUfIYAY3X9uXt4/sYUjvKvhNuQDV/I2DBHaPSI 5bgWL1zNf/zfsNi3H1r7TJANe/FInAB6fRdDoyJKd4uNthMb79CA/dJ6aUGf2BGjQ9s452D0w czHE090d/15DsIM6sqcw7/rv7F+sQVyzgthuicE21VWCe//u6ON/ZEnBgynlonBLj5eeNYpW8 Pz1VRP7EfoMfKuuAGzQ/TaGyjNTwA5uI170YzIFqcVXJxeJwx6/cI9+NjyHhI5L3xloS7t+5U 97RdXuQ+KuOaNoaB92j1pcKcVspiBN1cEota1g0oZTLZxyZ/uuBmp3fvZ5DaJbr6jnI7j0V+O fIhAPdwMjwB6o4tVQb6FbcUuyrcmF2ZfDZ68JFCLbVZ/c2xGsUDsfwlY7uULx3AH5tw+OP9Xs /pbpSoJoCw6/DC42AeOl4wpCwyolBpqMlAy8pU7BVbfDb94hFWCtydN0IlZ5WBfZ83jVfxrcC 86s1O/OO/BCsmrwQk0NwSzgB9WlgUYTwyBDQeFy+sVKxfnKIo1BEoXXbvmnEGo2aV098= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1969 Lines: 62 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 --- 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)) -- 2.9.0