cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
Subsystems (2)
PATCH 1/1 cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
The clk_get_parent() function doesn't return error pointers, it returns NULL on error. Update the error checking to match.
--- drivers/cpufreq/spear-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/spear-cpufreq.c +2 -2
@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)int ret =0 ; sys_clk =clk_get_parent (spear_cpufreq.clk); -if (IS_ERR (sys_clk)) { +if (!sys_clk) {pr_err ("failed to get cpu's parent (sys) clock\n" ); -return PTR_ERR (sys_clk); +return -EINVAL ; }/* Set the rate of the source clock before changing the parent */
Signature · 1 line
2.53.0
Quoted 5 lines · Dan Carpenter
The
clk_get_parent()function doesn't return error pointers, it returns NULL on error. Update the error checking to match.Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")Signed-off-by Dan Carpenter <[email protected]>
Nice catch, thanks for the fix.
Nit: the subject is too generic and can be misread as a cpufreq core fix. It is better to scope it to the driver, e.g. "cpufreq: spear: ...".
With that:
Quoted 20 lines
--- drivers/cpufreq/spear-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/cpufreq/spear-cpufreq.c +2
-2@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)int ret =0 ; sys_clk =clk_get_parent (spear_cpufreq.clk); -if (IS_ERR (sys_clk)) { +if (!sys_clk) {pr_err ("failed to get cpu's parent (sys) clock\n" ); -return PTR_ERR (sys_clk); +return -EINVAL ; }/* Set the rate of the source clock before changing the parent */
Signature · 2 lines
Thx and BRs, Zhongqiu Han
Viresh Kumar
maintainerQuoted 3 lines · Zhongqiu Han
Quoted 2 lines · Dan Carpenter
The
clk_get_parent()function doesn't return error pointers, it returns NULL on error. Update the error checking to match.
origin/master:include/linux/clk.h
/**
* clk_get_parent - get the parent clock source for this clock
* @clk: clock source
*
* Returns struct clk corresponding to parent clock source, or
* valid IS_ERR() condition containing errno.
*/
struct clk *clk_get_parent(struct clk *clk);
I think this is the source of the confusion.
Quoted 8 lines
Quoted 3 lines
Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")Signed-off-by Dan Carpenter <[email protected]>Nice catch, thanks for the fix.
Nit: the subject is too generic and can be misread as a cpufreq core fix. It is better to scope it to the driver, e.g. "cpufreq: spear: ...".
Right.
Signature · 1 line
viresh
Quoted 16 lines · Viresh Kumar
Quoted 3 lines · Zhongqiu Han
Quoted 2 lines · Dan Carpenter
The
clk_get_parent()function doesn't return error pointers, it returns NULL on error. Update the error checking to match.origin/master:include/linux/clk.h
/**
*clk_get_parent- get the parent clock source for this clock
* @clk: clock source
*
* Returns struct clk corresponding to parent clock source, or
* validIS_ERR()condition containing errno.
*/
struct clk *clk_get_parent(struct clk *clk);
Quoted 2 lines
I think this is the source of the confusion.
I'll send a separate patch to update that documentation.
regards,
dan carpenter
Quoted 4 lines · Zhongqiu Han
Quoted 3 lines · Dan Carpenter
The
clk_get_parent()function doesn't return error pointers, it returns NULL on error. Update the error checking to match.
Quoted 8 lines
Quoted 2 lines
Fixes 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")Signed-off-by Dan Carpenter <[email protected]>Nice catch, thanks for the fix.
Nit: the subject is too generic and can be misread as a cpufreq core fix. It is better to scope it to the driver, e.g. "cpufreq: spear: ...".
Oops. Sorry.
regards,
dan carpenter