Skip to contentSkip to conversation

ACPI: thermal_lib: Initialize temp_decik to zero

PATCH Applied Colin Ian King 2 participants 2 messages Feb 22, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ACPI: thermal_lib: Initialize temp_decik to zero

Static analysis with clang scan build is warning that uninitialized data is being passed into various functions. Stop these warnings by initializing temp_decik to zero.

Cleans up clang scan warnings in lines 106, 125, 146 and 164 such as:
drivers/acpi/thermal_lib.c:106:9: warning: 2nd function call argument is an uninitialized value [core.CallAndMessage]

Kudos to Dan Carpenter for the deeper analysis of this issue.

---

V2: just set temp_decik to 0

---
 drivers/acpi/thermal_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/thermal_lib.c +4 -4
index 4e0519ca9739..6214d6ebe1fa 100644
@@ -100,7 +100,7 @@ static int thermal_temp(int error, int temp_decik, int *ret_temp)
  */
 int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
 {
-	int temp_decik;
+	int temp_decik = 0;
 	int ret = acpi_active_trip_temp(adev, id, &temp_decik);
 
 	return thermal_temp(ret, temp_decik, ret_temp);
@@ -119,7 +119,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_active_trip_temp);
  */
 int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-	int temp_decik;
+	int temp_decik = 0;
 	int ret = acpi_passive_trip_temp(adev, &temp_decik);
 
 	return thermal_temp(ret, temp_decik, ret_temp);
@@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_passive_trip_temp);
  */
 int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-	int temp_decik;
+	int temp_decik = 0;
 	int ret = acpi_hot_trip_temp(adev, &temp_decik);
 
 	return thermal_temp(ret, temp_decik, ret_temp);
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_hot_trip_temp);
  */
 int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-	int temp_decik;
+	int temp_decik = 0;
 	int ret = acpi_critical_trip_temp(adev, &temp_decik);
 
 	return thermal_temp(ret, temp_decik, ret_temp);
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw
Quoted 52 lines · Colin Ian King

Static analysis with clang scan build is warning that uninitialized data is being passed into various functions. Stop these warnings by initializing temp_decik to zero.

Cleans up clang scan warnings in lines 106, 125, 146 and 164 such as:
drivers/acpi/thermal_lib.c:106:9: warning: 2nd function call argument is an uninitialized value [core.CallAndMessage]

Kudos to Dan Carpenter for the deeper analysis of this issue.

---

V2: just set temp_decik to 0

---
 drivers/acpi/thermal_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/thermal_lib.c +3 -3
index 4e0519ca9739..6214d6ebe1fa 100644
@@ -100,7 +100,7 @@ static int thermal_temp(int error, int temp_decik, int *ret_temp)
  */
 int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
 {
-       int temp_decik;
+       int temp_decik = 0;
        int ret = acpi_active_trip_temp(adev, id, &temp_decik);
 
        return thermal_temp(ret, temp_decik, ret_temp);
@@ -119,7 +119,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_active_trip_temp);
  */
 int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-       int temp_decik;
+       int temp_decik = 0;
        int ret = acpi_passive_trip_temp(adev, &temp_decik);
 
        return thermal_temp(ret, temp_decik, ret_temp);
@@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_passive_trip_temp);
  */
 int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-       int temp_decik;
+       int temp_decik = 0;
        int ret = acpi_hot_trip_temp(adev, &temp_decik);
 
        return thermal_temp(ret, temp_decik, ret_temp);

drivers/acpi/thermal_lib.c EXPORT_SYMBOL_GPL(thermal_acpi_hot_trip_temp);

Quoted 9 lines
drivers/acpi/thermal_lib.c +1 -2
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(thermal_acpi_hot_trip_temp);
  */
 int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
 {
-       int temp_decik;
+       int temp_decik = 0;
        int ret = acpi_critical_trip_temp(adev, &temp_decik);
 
        return thermal_temp(ret, temp_decik, ret_temp);
--

Applied as 6.9 material, thanks!