mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq: cppc: Fix invalid return value in .get() callback
@ 2025-04-13 10:11 Marc Zyngier
  2025-04-14  1:35 ` zhenglifeng (A)
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2025-04-13 10:11 UTC (permalink / raw)
  To: linux-kernel, linux-pm; +Cc: stable, Rafael J. Wysocki, Viresh Kumar

Returning a negative error code in a function with an unsigned
return type is a pretty bad idea. It is probably worse when the
justification for the change is "our static analisys tool found it".

Fixes: cf7de25878a1 ("cppc_cpufreq: Fix possible null pointer dereference")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cppc_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index b3d74f9adcf0b..cb93f00bafdba 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
 	int ret;
 
 	if (!policy)
-		return -ENODEV;
+		return 0;
 
 	cpu_data = policy->driver_data;
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: cppc: Fix invalid return value in .get() callback
  2025-04-13 10:11 [PATCH] cpufreq: cppc: Fix invalid return value in .get() callback Marc Zyngier
@ 2025-04-14  1:35 ` zhenglifeng (A)
  2025-04-16  8:08   ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: zhenglifeng (A) @ 2025-04-14  1:35 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel, linux-pm
  Cc: stable, Rafael J. Wysocki, Viresh Kumar

On 2025/4/13 18:11, Marc Zyngier wrote:

> Returning a negative error code in a function with an unsigned
> return type is a pretty bad idea. It is probably worse when the
> justification for the change is "our static analisys tool found it".
> 
> Fixes: cf7de25878a1 ("cppc_cpufreq: Fix possible null pointer dereference")
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: stable@vger.kernel.org
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index b3d74f9adcf0b..cb93f00bafdba 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
>  	int ret;
>  
>  	if (!policy)
> -		return -ENODEV;
> +		return 0;
>  
>  	cpu_data = policy->driver_data;
>  

Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: cppc: Fix invalid return value in .get() callback
  2025-04-14  1:35 ` zhenglifeng (A)
@ 2025-04-16  8:08   ` Viresh Kumar
  0 siblings, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2025-04-16  8:08 UTC (permalink / raw)
  To: zhenglifeng (A)
  Cc: Marc Zyngier, linux-kernel, linux-pm, stable, Rafael J. Wysocki

On 14-04-25, 09:35, zhenglifeng (A) wrote:
> On 2025/4/13 18:11, Marc Zyngier wrote:
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> > index b3d74f9adcf0b..cb93f00bafdba 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -747,7 +747,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
> >  	int ret;
> >  
> >  	if (!policy)
> > -		return -ENODEV;
> > +		return 0;
> >  
> >  	cpu_data = policy->driver_data;
> >  
> 
> Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>

Applied. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-16  8:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-13 10:11 [PATCH] cpufreq: cppc: Fix invalid return value in .get() callback Marc Zyngier
2025-04-14  1:35 ` zhenglifeng (A)
2025-04-16  8:08   ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®