All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal/core: fix error code in __thermal_cooling_device_register()
@ 2022-10-28 15:02 Dan Carpenter
  2022-10-28 18:00 ` Rafael J. Wysocki
  2022-10-31  5:02 ` Viresh Kumar
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-10-28 15:02 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar
  Cc: Daniel Lezcano, Amit Kucheria, Zhang Rui, linux-pm, kernel-janitors

Return an error pointer if ->get_max_state() fails.  The current code
returns NULL which will cause an oops in the callers.

Fixes: c408b3d1d9bb ("thermal: Validate new state in cur_state_store()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/thermal/thermal_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 4ba7b524e5de..c4d18e462de8 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -892,7 +892,8 @@ __thermal_cooling_device_register(struct device_node *np,
 	cdev->device.class = &thermal_class;
 	cdev->devdata = devdata;
 
-	if (cdev->ops->get_max_state(cdev, &cdev->max_state))
+	ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
+	if (ret)
 		goto out_kfree_type;
 
 	thermal_cooling_device_setup_sysfs(cdev);
-- 
2.35.1


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

* Re: [PATCH] thermal/core: fix error code in __thermal_cooling_device_register()
  2022-10-28 15:02 [PATCH] thermal/core: fix error code in __thermal_cooling_device_register() Dan Carpenter
@ 2022-10-28 18:00 ` Rafael J. Wysocki
  2022-10-31  5:02 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-10-28 18:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rafael J. Wysocki, Viresh Kumar, Daniel Lezcano, Amit Kucheria,
	Zhang Rui, linux-pm, kernel-janitors

On Fri, Oct 28, 2022 at 5:02 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Return an error pointer if ->get_max_state() fails.  The current code
> returns NULL which will cause an oops in the callers.
>
> Fixes: c408b3d1d9bb ("thermal: Validate new state in cur_state_store()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/thermal/thermal_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 4ba7b524e5de..c4d18e462de8 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -892,7 +892,8 @@ __thermal_cooling_device_register(struct device_node *np,
>         cdev->device.class = &thermal_class;
>         cdev->devdata = devdata;
>
> -       if (cdev->ops->get_max_state(cdev, &cdev->max_state))
> +       ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
> +       if (ret)
>                 goto out_kfree_type;
>
>         thermal_cooling_device_setup_sysfs(cdev);
> --

Applied, thanks!

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

* Re: [PATCH] thermal/core: fix error code in __thermal_cooling_device_register()
  2022-10-28 15:02 [PATCH] thermal/core: fix error code in __thermal_cooling_device_register() Dan Carpenter
  2022-10-28 18:00 ` Rafael J. Wysocki
@ 2022-10-31  5:02 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2022-10-31  5:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	linux-pm, kernel-janitors

On 28-10-22, 18:02, Dan Carpenter wrote:
> Return an error pointer if ->get_max_state() fails.  The current code
> returns NULL which will cause an oops in the callers.
> 
> Fixes: c408b3d1d9bb ("thermal: Validate new state in cur_state_store()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/thermal/thermal_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 4ba7b524e5de..c4d18e462de8 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -892,7 +892,8 @@ __thermal_cooling_device_register(struct device_node *np,
>  	cdev->device.class = &thermal_class;
>  	cdev->devdata = devdata;
>  
> -	if (cdev->ops->get_max_state(cdev, &cdev->max_state))
> +	ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
> +	if (ret)
>  		goto out_kfree_type;
>  
>  	thermal_cooling_device_setup_sysfs(cdev);

Bad mistake.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
-- 
viresh

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

end of thread, other threads:[~2022-10-31  5:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 15:02 [PATCH] thermal/core: fix error code in __thermal_cooling_device_register() Dan Carpenter
2022-10-28 18:00 ` Rafael J. Wysocki
2022-10-31  5:02 ` Viresh Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.