* [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
@ 2026-07-10 19:34 Dan Carpenter
2026-07-12 13:30 ` Zhongqiu Han
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2026-07-10 19:34 UTC (permalink / raw)
To: Deepak Sikri
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, linux-kernel,
kernel-janitors
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>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
2026-07-10 19:34 [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate() Dan Carpenter
@ 2026-07-12 13:30 ` Zhongqiu Han
2026-07-13 4:01 ` Viresh Kumar
2026-07-13 7:45 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Zhongqiu Han @ 2026-07-12 13:30 UTC (permalink / raw)
To: Dan Carpenter, Deepak Sikri
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, linux-kernel,
kernel-janitors, zhongqiu.han
On 7/11/2026 3:34 AM, 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>
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:
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
2026-07-12 13:30 ` Zhongqiu Han
@ 2026-07-13 4:01 ` Viresh Kumar
2026-07-13 7:56 ` Dan Carpenter
2026-07-13 7:45 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2026-07-13 4:01 UTC (permalink / raw)
To: Zhongqiu Han
Cc: Dan Carpenter, Deepak Sikri, Rafael J. Wysocki, linux-pm,
linux-kernel, kernel-janitors
On 12-07-26, 21:30, Zhongqiu Han wrote:
> On 7/11/2026 3:34 AM, Dan Carpenter wrote:
> > 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.
> >
> > Fixes: 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> 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.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
2026-07-13 4:01 ` Viresh Kumar
@ 2026-07-13 7:56 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2026-07-13 7:56 UTC (permalink / raw)
To: Viresh Kumar
Cc: Zhongqiu Han, Deepak Sikri, Rafael J. Wysocki, linux-pm,
linux-kernel, kernel-janitors
On Mon, Jul 13, 2026 at 09:31:12AM +0530, Viresh Kumar wrote:
> On 12-07-26, 21:30, Zhongqiu Han wrote:
> > On 7/11/2026 3:34 AM, Dan Carpenter wrote:
> > > 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.
>
I'll send a separate patch to update that documentation.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate()
2026-07-12 13:30 ` Zhongqiu Han
2026-07-13 4:01 ` Viresh Kumar
@ 2026-07-13 7:45 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2026-07-13 7:45 UTC (permalink / raw)
To: Zhongqiu Han
Cc: Deepak Sikri, Rafael J. Wysocki, Viresh Kumar, linux-pm,
linux-kernel, kernel-janitors
On Sun, Jul 12, 2026 at 09:30:16PM +0800, Zhongqiu Han wrote:
> On 7/11/2026 3:34 AM, 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>
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-13 7:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 19:34 [PATCH] cpufreq: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate() Dan Carpenter
2026-07-12 13:30 ` Zhongqiu Han
2026-07-13 4:01 ` Viresh Kumar
2026-07-13 7:56 ` Dan Carpenter
2026-07-13 7:45 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox