clk: __clk_set_parent: set uninitialized variable
PATCH 1/1 clk: __clk_set_parent: set uninitialized variable
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 <[email protected]>
Date: Wed Jun 6 14:41:31 2012 +0530
clk: Allow late cache allocation for clk->parentsThis patch applies to linux-3.5-rc5
---
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(-)
drivers/clk/clk.c +1 -1
@@ -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;
Signature · 1 line
1.7.10
PATCH 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 6 lines · Marc Kleine-Budde
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.
Quoted 36 lines
commit 7975059db572eb47f0fb272a62afeae272a4b209 Author: Rajendra Nayak<[email protected]> Date: Wed Jun 6 14:41:31 2012 +0530 clk: Allow late cache allocation for clk->parentsThis patch applies to linux-3.5-rc5
Cc Rajendra Nayak<[email protected]>Signed-off-by Marc Kleine-Budde<[email protected]>---
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(-)drivers/clk/clk.c +1
-1@@ -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;
PATCH 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 11 lines · Rajendra Nayak
Quoted 6 lines · Marc Kleine-Budde
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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 clk: __clk_set_parent: set uninitialized variable
Quoted 25 lines · Uwe Kleine-K?nig
Quoted 11 lines · Rajendra Nayak
Quoted 6 lines · Marc Kleine-Budde
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:
(quoted diff) +7
-3- 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);
Quoted 1 line
results in i being uninitialized if
clk->parentsis NULL. But I wonder
ok, got it.
Quoted 1 line
if for this case i should be set to
clk->num_parentsinstead of 0?
yes, that seems like the right thing to do.
Quoted 4 lines
Best regards
Uwe