[PATCH 2/2] thermal: exynos: Add error handling for temperature code

From: Jonghwan Choi
Date: Tue Nov 27 2012 - 19:48:11 EST


If temperature code is invalid, it should be handled.

Signed-off-by: Jonghwan Choi <jhbird.choi@xxxxxxxxxxx>
---
drivers/thermal/exynos_thermal.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c
b/drivers/thermal/exynos_thermal.c
index dc2ad6c..78c5c08 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -346,15 +346,19 @@ static int exynos_get_temp(struct thermal_zone_device
*thermal,
unsigned long *temp)
{
void *data;
+ int tmp;

if (!th_zone->sensor_conf) {
pr_info("Temperature sensor not initialised\n");
return -EINVAL;
}
data = th_zone->sensor_conf->private_data;
- *temp = th_zone->sensor_conf->read_temperature(data);
+ tmp = th_zone->sensor_conf->read_temperature(data);
+ if (tmp < 0)
+ return tmp;
+
/* convert the temperature into millicelsius */
- *temp = *temp * MCELSIUS;
+ *temp = tmp * MCELSIUS;
return 0;
}

--
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/