[PATCH v2] cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()

Dan Carpenter posted 1 patch 1 week, 4 days ago
drivers/cpufreq/spear-cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
Posted by Dan Carpenter 1 week, 4 days ago
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 <error27@gmail.com>
---
v2: fix subsystem prefix in subject

 drivers/cpufreq/spear-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 81a0780b2ebf..ffe5eda82f0b 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -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 */
-- 
2.53.0
Re: [PATCH v2] cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
Posted by Zhongqiu Han 1 week, 3 days ago
On 7/14/2026 11:46 PM, Dan Carpenter wrote:
> 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 <error27@gmail.com>
> ---
> v2: fix subsystem prefix in subject

Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>


> 
>   drivers/cpufreq/spear-cpufreq.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
> index 81a0780b2ebf..ffe5eda82f0b 100644
> --- a/drivers/cpufreq/spear-cpufreq.c
> +++ b/drivers/cpufreq/spear-cpufreq.c
> @@ -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 */


-- 
Thx and BRs,
Zhongqiu Han
Re: [PATCH v2] cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
Posted by Viresh Kumar 1 week, 3 days ago
On 15-07-26, 08:10, Zhongqiu Han wrote:
> On 7/14/2026 11:46 PM, Dan Carpenter wrote:
> > 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 <error27@gmail.com>
> > ---
> > v2: fix subsystem prefix in subject
> 
> Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>

Applied. Thanks.

-- 
viresh