Skip to contentSkip to conversation

thermal: helpers: Check return value of get_temp

PATCH RESEND In review Rhyland Klein 2 participants 4 messages Jun 6, 2016 – Jul 28, 2016 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 thermal: helpers: Check return value of get_temp

Check the return value of get_temp, which can fail. If it does, then unlock and return the error code.

---
 drivers/thermal/thermal_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/thermal_helpers.c +4 -0
index 5e1c160944c9..dc260749f8d6 100644
@@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
 	mutex_lock(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
+	if (!ret) {
+		mutex_unlock(&tz->lock);
+		goto exit;
+	}
 
 	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
 		for (count = 0; count < tz->trips; count++) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Rhyland Klein

Check the return value of get_temp, which can fail. If it does, then unlock and return the error code.

---
 drivers/thermal/thermal_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/thermal_helpers.c +0 -0
index 5e1c160944c9..dc260749f8d6 100644

drivers/thermal/thermal_helpers.c int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) · line 99

Quoted 10 lines
drivers/thermal/thermal_helpers.c +4 -0
@@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
 	mutex_lock(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
+	if (!ret) {
+		mutex_unlock(&tz->lock);
+		goto exit;
+	}
 
 	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
 		for (count = 0; count < tz->trips; count++) {

I haven't seen any comments on this. Has anyone had a chance to take a look at it yet?

-rhyland

Signature · 1 line
nvpublic
#2 lore raw
In reply to Rhyland Klein
Quoted 14 lines · Rhyland Klein

Check the return value of get_temp, which can fail. If it does, then unlock and return the error code.

---
 drivers/thermal/thermal_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/thermal_helpers.c +0 -0
index 5e1c160944c9..dc260749f8d6 100644

drivers/thermal/thermal_helpers.c int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) · line 99

Quoted 10 lines
drivers/thermal/thermal_helpers.c +4 -0
@@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
 	mutex_lock(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
+	if (!ret) {
+		mutex_unlock(&tz->lock);
+		goto exit;
+	}
 
 	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
 		for (count = 0; count < tz->trips; count++) {

I haven't seen any comments on this patch, has anyone had a chance to review it yet?

-rhyland

Signature · 1 line
nvpublic
reviewer
#3 lore raw
Quoted 27 lines · Rhyland Klein
Quoted 26 lines · Rhyland Klein

Check the return value of get_temp, which can fail. If it does, then
unlock and return the error code.

---
 drivers/thermal/thermal_helpers.c | 4 ++++

 1 file changed, 4 insertions(+)
drivers/thermal/thermal_helpers.c +0 -0
index 5e1c160944c9..dc260749f8d6 100644
@@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct
 thermal_zone_device *tz, int *temp)
  	mutex_lock(&tz->lock);


  ret = tz->ops->get_temp(tz, temp);

drivers/thermal/thermal_helpers.c +4 -0
+	if (!ret) {
+		mutex_unlock(&tz->lock);
+		goto exit;
+	}


  if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz-

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

emul_temperature) {

  for (count = 0; count < tz->trips; count++) {

I haven't seen any comments on this patch, has anyone had a chance to review it yet?

Patch applied, it would be merged together with the thermal reorg patches.

thanks,
rui