* [PATCH] clk: __clk_set_parent: set uninitialized variable
@ 2012-07-01 21:18 Marc Kleine-Budde
2012-07-02 5:57 ` Rajendra Nayak
0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2012-07-01 21:18 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes the following warning:
drivers/clk/clk.c: In function '__clk_set_parent':
drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
which has been introduced with commit:
commit 7975059db572eb47f0fb272a62afeae272a4b209
Author: Rajendra Nayak <rnayak@ti.com>
Date: Wed Jun 6 14:41:31 2012 +0530
clk: Allow late cache allocation for clk->parents
This patch applies to linux-3.5-rc5
Cc: Rajendra Nayak <rnayak@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hello,
please check if this is the correct fix. The original patch has been
schedules for stable, this fix may be a candicate, too.
regards, Marc
drivers/clk/clk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index dcbe056..60d1bb4 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1063,7 +1063,7 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
struct clk *old_parent;
unsigned long flags;
int ret = -EINVAL;
- u8 i;
+ u8 i = 0;
old_parent = clk->parent;
--
1.7.10
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] clk: __clk_set_parent: set uninitialized variable
2012-07-01 21:18 [PATCH] clk: __clk_set_parent: set uninitialized variable Marc Kleine-Budde
@ 2012-07-02 5:57 ` Rajendra Nayak
2012-07-02 6:47 ` Uwe Kleine-König
0 siblings, 1 reply; 4+ messages in thread
From: Rajendra Nayak @ 2012-07-02 5:57 UTC (permalink / raw)
To: linux-arm-kernel
On Monday 02 July 2012 02:48 AM, Marc Kleine-Budde wrote:
> This patch fixes the following warning:
>
> drivers/clk/clk.c: In function '__clk_set_parent':
> drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
>
> which has been introduced with commit:
hmm, are you sure about that? The below commit neither introduces the
variable 'i', nor seem to change the way the variable is used in the
function.
>
> commit 7975059db572eb47f0fb272a62afeae272a4b209
> Author: Rajendra Nayak<rnayak@ti.com>
> Date: Wed Jun 6 14:41:31 2012 +0530
>
> clk: Allow late cache allocation for clk->parents
>
> This patch applies to linux-3.5-rc5
>
> Cc: Rajendra Nayak<rnayak@ti.com>
> Signed-off-by: Marc Kleine-Budde<mkl@pengutronix.de>
> ---
> Hello,
>
> please check if this is the correct fix. The original patch has been
> schedules for stable, this fix may be a candicate, too.
>
> regards, Marc
>
>
> drivers/clk/clk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index dcbe056..60d1bb4 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -1063,7 +1063,7 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
> struct clk *old_parent;
> unsigned long flags;
> int ret = -EINVAL;
> - u8 i;
> + u8 i = 0;
>
> old_parent = clk->parent;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clk: __clk_set_parent: set uninitialized variable
2012-07-02 5:57 ` Rajendra Nayak
@ 2012-07-02 6:47 ` Uwe Kleine-König
2012-07-02 7:24 ` Rajendra Nayak
0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2012-07-02 6:47 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jul 02, 2012 at 11:27:13AM +0530, Rajendra Nayak wrote:
> On Monday 02 July 2012 02:48 AM, Marc Kleine-Budde wrote:
> >This patch fixes the following warning:
> >
> > drivers/clk/clk.c: In function '__clk_set_parent':
> > drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
> >
> >which has been introduced with commit:
>
> hmm, are you sure about that? The below commit neither introduces the
> variable 'i', nor seem to change the way the variable is used in the
> function.
It does. The following hunk:
- for (i = 0; i < clk->num_parents; i++)
- if (clk->parents[i] == parent)
- break;
+ if (clk->parents)
+ for (i = 0; i < clk->num_parents; i++)
+ if (clk->parents[i] == parent)
+ break;
+ else
+ clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
+ GFP_KERNEL);
results in i being uninitialized if clk->parents is NULL. But I wonder
if for this case i should be set to clk->num_parents instead of 0?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clk: __clk_set_parent: set uninitialized variable
2012-07-02 6:47 ` Uwe Kleine-König
@ 2012-07-02 7:24 ` Rajendra Nayak
0 siblings, 0 replies; 4+ messages in thread
From: Rajendra Nayak @ 2012-07-02 7:24 UTC (permalink / raw)
To: linux-arm-kernel
On Monday 02 July 2012 12:17 PM, Uwe Kleine-K?nig wrote:
> On Mon, Jul 02, 2012 at 11:27:13AM +0530, Rajendra Nayak wrote:
>> On Monday 02 July 2012 02:48 AM, Marc Kleine-Budde wrote:
>>> This patch fixes the following warning:
>>>
>>> drivers/clk/clk.c: In function '__clk_set_parent':
>>> drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
>>>
>>> which has been introduced with commit:
>>
>> hmm, are you sure about that? The below commit neither introduces the
>> variable 'i', nor seem to change the way the variable is used in the
>> function.
> It does. The following hunk:
>
> - for (i = 0; i< clk->num_parents; i++)
> - if (clk->parents[i] == parent)
> - break;
> + if (clk->parents)
> + for (i = 0; i< clk->num_parents; i++)
> + if (clk->parents[i] == parent)
> + break;
> + else
> + clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
> + GFP_KERNEL);
>
> results in i being uninitialized if clk->parents is NULL. But I wonder
ok, got it.
> if for this case i should be set to clk->num_parents instead of 0?
yes, that seems like the right thing to do.
>
> Best regards
> Uwe
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-02 7:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-01 21:18 [PATCH] clk: __clk_set_parent: set uninitialized variable Marc Kleine-Budde
2012-07-02 5:57 ` Rajendra Nayak
2012-07-02 6:47 ` Uwe Kleine-König
2012-07-02 7:24 ` Rajendra Nayak
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).