Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v1] thermal: intel: int340x: Fix unitialized variable error
@ 2023-01-24 16:38 Rafael J. Wysocki
  2023-01-24 16:40 ` Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-01-24 16:38 UTC (permalink / raw)
  To: Linux PM
  Cc: LKML, Srinivas Pandruvada, Zhang Rui, Daniel Lezcano,
	Dan Carpenter

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

If PATC evaluation fails in int340x_thermal_zone_add(), trip_cnt will
not be initialized when allocating the trips array later.

Address this by initializing trip_cnt to 0.

While at it, move the status variable definition lower for better
code readability.

Fixes: d58c653e9e26 ("thermal: intel: int340x: Use generic trip points")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -120,9 +120,9 @@ struct int34x_thermal_zone *int340x_ther
 						     int (*get_temp) (struct thermal_zone_device *, int *))
 {
 	struct int34x_thermal_zone *int34x_thermal_zone;
-	acpi_status status;
-	unsigned long long trip_cnt;
+	unsigned long long trip_cnt = 0;
 	int trip_mask = 0;
+	acpi_status status;
 	int i, ret;
 
 	int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone),




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

* Re: [PATCH v1] thermal: intel: int340x: Fix unitialized variable error
  2023-01-24 16:38 [PATCH v1] thermal: intel: int340x: Fix unitialized variable error Rafael J. Wysocki
@ 2023-01-24 16:40 ` Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2023-01-24 16:40 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM
  Cc: LKML, Srinivas Pandruvada, Zhang Rui, Dan Carpenter

On 24/01/2023 17:38, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> If PATC evaluation fails in int340x_thermal_zone_add(), trip_cnt will
> not be initialized when allocating the trips array later.
> 
> Address this by initializing trip_cnt to 0.
> 
> While at it, move the status variable definition lower for better
> code readability.
> 
> Fixes: d58c653e9e26 ("thermal: intel: int340x: Use generic trip points")
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

end of thread, other threads:[~2023-01-24 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-24 16:38 [PATCH v1] thermal: intel: int340x: Fix unitialized variable error Rafael J. Wysocki
2023-01-24 16:40 ` Daniel Lezcano

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