diff mbox series

thermal/drivers/cpu_cooling: Fix an IS_ERR() vs NULL bug

Message ID 20191220053750.4wcxgieqmceyhwo5@kili.mountain (mailing list archive)
State Not Applicable, archived
Headers show
Series thermal/drivers/cpu_cooling: Fix an IS_ERR() vs NULL bug | expand

Commit Message

Dan Carpenter Dec. 20, 2019, 5:40 a.m. UTC
The idle_inject_register() function returns NULL on error, it never
returns error pointers.

Fixes: 1e044f70e5c2 ("thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/thermal/cpuidle_cooling.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Viresh Kumar Dec. 20, 2019, 6:17 a.m. UTC | #1
On 20-12-19, 08:40, Dan Carpenter wrote:
> The idle_inject_register() function returns NULL on error, it never
> returns error pointers.
> 
> Fixes: 1e044f70e5c2 ("thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/thermal/cpuidle_cooling.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
> index 6d778acefeec..ab48387ce868 100644
> --- a/drivers/thermal/cpuidle_cooling.c
> +++ b/drivers/thermal/cpuidle_cooling.c
> @@ -187,8 +187,8 @@ __init cpuidle_of_cooling_register(struct device_node *np,
>  	}
>  
>  	ii_dev = idle_inject_register(drv->cpumask);
> -	if (IS_ERR(ii_dev)) {
> -		ret = PTR_ERR(ii_dev);
> +	if (!ii_dev) {
> +		ret = -ENOMEM;
>  		goto out_id;
>  	}

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Daniel Lezcano Dec. 20, 2019, 8:29 a.m. UTC | #2
Hi Dan,

On 20/12/2019 06:40, Dan Carpenter wrote:
> The idle_inject_register() function returns NULL on error, it never
> returns error pointers.
> 
> Fixes: 1e044f70e5c2 ("thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for the fix. It was fixed with the V5 version.
diff mbox series

Patch

diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index 6d778acefeec..ab48387ce868 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -187,8 +187,8 @@  __init cpuidle_of_cooling_register(struct device_node *np,
 	}
 
 	ii_dev = idle_inject_register(drv->cpumask);
-	if (IS_ERR(ii_dev)) {
-		ret = PTR_ERR(ii_dev);
+	if (!ii_dev) {
+		ret = -ENOMEM;
 		goto out_id;
 	}