cpufreq: spear: Fix uninitialized variable "i"
PATCH 1/1 cpufreq: spear: Fix uninitialized variable "i"
The refactoring in commit dca2ef2b7d91 ("cpufreq: spear: Use of_property_for_each_u32() instead of open coding") left "i" uninitialized. Initialize it to 0.
Note that gcc doesn't detect this, only clang does.
--- drivers/cpufreq/spear-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/spear-cpufreq.c +1 -1
@@ -173,7 +173,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)struct device_node *np;struct cpufreq_frequency_table *freq_tbl;u32 val; -int cnt, i, ret; +int cnt, i =0 , ret; np =of_cpu_device_node_get (0 );if (!np) {
Signature · 1 line
2.43.0
Viresh Kumar
maintainerQuoted 19 lines · Rob Herring (Arm)
The refactoring in commit
dca2ef2b7d91("cpufreq: spear: Useof_property_for_each_u32()instead of open coding") left "i" uninitialized. Initialize it to 0.Note that gcc doesn't detect this, only clang does.
Fixes dca2ef2b7d91 ("cpufreq: spear: Use of_property_for_each_u32() instead of open coding")Reported-by kernel test robot <[email protected]>Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/cpufreq/spear-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/spear-cpufreq.c +0
-0
drivers/cpufreq/spear-cpufreq.c static int spear_cpufreq_probe(struct platform_device *pdev) · line 176
Quoted 5 lines
drivers/cpufreq/spear-cpufreq.c +1
-1@@ -173,7 +173,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)struct device_node *np;struct cpufreq_frequency_table *freq_tbl;u32 val; -int cnt, i, ret; +int cnt, i =0 , ret;
We don't increment 'i' anymore, don't we need an i++ in:
freq_tbl[i].frequency = val;
?
Signature · 1 line
viresh
Quoted 29 lines · Viresh Kumar
Quoted 19 lines · Rob Herring (Arm)
The refactoring in commit
dca2ef2b7d91("cpufreq: spear: Useof_property_for_each_u32()instead of open coding") left "i" uninitialized. Initialize it to 0.Note that gcc doesn't detect this, only clang does.
Fixes dca2ef2b7d91 ("cpufreq: spear: Use of_property_for_each_u32() instead of open coding")Reported-by kernel test robot <[email protected]>Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/cpufreq/spear-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cpufreq/spear-cpufreq.c +0
-0drivers/cpufreq/spear-cpufreq.c static int spear_cpufreq_probe(struct platform_device *pdev) · line 176
Quoted 5 lines
drivers/cpufreq/spear-cpufreq.c +1
-1@@ -173,7 +173,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)struct device_node *np;struct cpufreq_frequency_table *freq_tbl;u32 val; -int cnt, i, ret; +int cnt, i =0 , ret;We don't increment 'i' anymore, don't we need an i++ in:
Quoted 3 lines
freq_tbl[i].frequency = val;?
Sigh. Yes.
Rob
Viresh Kumar
maintainerQuoted 8 lines · Rob Herring
Quoted 5 lines · Viresh Kumar
We don't increment 'i' anymore, don't we need an i++ in:
freq_tbl[i].frequency = val;?
Sigh. Yes.
Fixed the original commit with this, hope this doesn't add any new bugs:
drivers/cpufreq/spear-cpufreq.c +2 -2
@@ -173,7 +173,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)struct device_node *np;struct cpufreq_frequency_table *freq_tbl;u32 val; -int cnt, i, ret; +int cnt, ret, i =0 ; np =of_cpu_device_node_get (0 );if (!np) {
@@ -199,7 +199,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev) }of_property_for_each_u32 (np,"cpufreq_tbl" , val) - freq_tbl[i].frequency = val; + freq_tbl[i++].frequency = val; freq_tbl[cnt].frequency =CPUFREQ_TABLE_END ;
Signature · 1 line
viresh