2015-05-18 03:45:31

by Ricky Liang

[permalink] [raw]
Subject: [PATCH v2] clk: mediatek: Initialize clk_init_data

The variable init (struct clk_init_data) is allocated on the stack.
We weren't initializing the .flags field, so it contains random junk,
which can cause all kinds of interesting issues when the flags are
parsed by clk_register.

Signed-off-by: Ricky Liang <[email protected]>
---
drivers/clk/mediatek/clk-pll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 66154ca..44409e9 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -268,7 +268,7 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data,
void __iomem *base)
{
struct mtk_clk_pll *pll;
- struct clk_init_data init;
+ struct clk_init_data init = {};
struct clk *clk;
const char *parent_name = "clk26m";

--
2.1.2


2015-05-18 05:54:39

by Sascha Hauer

[permalink] [raw]
Subject: Re: [PATCH v2] clk: mediatek: Initialize clk_init_data

Hi Ricky,

On Mon, May 18, 2015 at 11:41:49AM +0800, Ricky Liang wrote:
> The variable init (struct clk_init_data) is allocated on the stack.
> We weren't initializing the .flags field, so it contains random junk,
> which can cause all kinds of interesting issues when the flags are
> parsed by clk_register.

It seems we have the same problem in clk-gate.c aswell. We do initialize
do .flags field there, so this is no urgent problem, but we might get a
real problem when additional fields are added to struct clk_init_data.
Care to fix that aswell along with this patch?

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2015-05-18 13:57:19

by Ricky Liang

[permalink] [raw]
Subject: Re: [PATCH v2] clk: mediatek: Initialize clk_init_data

Hi Sascha,

Sure. I can fix clk-gate.c as well. New patch on the way...

-Ricky

On Mon, May 18, 2015 at 1:54 PM, Sascha Hauer <[email protected]> wrote:
> Hi Ricky,
>
> On Mon, May 18, 2015 at 11:41:49AM +0800, Ricky Liang wrote:
>> The variable init (struct clk_init_data) is allocated on the stack.
>> We weren't initializing the .flags field, so it contains random junk,
>> which can cause all kinds of interesting issues when the flags are
>> parsed by clk_register.
>
> It seems we have the same problem in clk-gate.c aswell. We do initialize
> do .flags field there, so this is no urgent problem, but we might get a
> real problem when additional fields are added to struct clk_init_data.
> Care to fix that aswell along with this patch?
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |