Skip to contentSkip to conversation

thermal: exynos: fix: Check if data->tmu_read callback is present before read

PATCH In review Lukasz Majewski 2 participants 3 messages Feb 6, 2015 – Feb 19, 2015

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

PATCH 1/1 thermal: exynos: fix: Check if data->tmu_read callback is present before read

The exynos_tmu_data() function should on entrance test not only for valid data pointer, but also for data->tmu_read one.
It is important, since afterwards it is dereferenced to get temperature code.

---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/samsung/exynos_tmu.c +1 -1
index 3a19353..a86e0495e 100644
@@ -717,7 +717,7 @@ static int exynos_get_temp(void *p, long *temp)
 {
 	struct exynos_tmu_data *data = p;
 
-	if (!data)
+	if (!data || !data->tmu_read)
 		return -EINVAL;
 
 	mutex_lock(&data->lock);
Signature · 1 line
2.0.0.rc2
#1 lore raw

Hi Eduardo,

Quoted 15 lines

The exynos_tmu_data() function should on entrance test not only for valid data pointer, but also for data->tmu_read one.
It is important, since afterwards it is dereferenced to get temperature code.

---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.c index 3a19353..a86e0495e 100644

drivers/thermal/samsung/exynos_tmu.c static int exynos_get_temp(void *p, long *temp) · line 723

Quoted 8 lines
drivers/thermal/samsung/exynos_tmu.c +1 -1
@@ -717,7 +717,7 @@ static int exynos_get_temp(void *p, long *temp)
 {
 	struct exynos_tmu_data *data = p;
 
-	if (!data)
+	if (!data || !data->tmu_read)
 		return -EINVAL;
 
 	mutex_lock(&data->lock);

This fix shall be added to v3.20.

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#2 lore raw

Hi Lukasz,

Quoted 20 lines · Lukasz Majewski

Hi Eduardo,

Quoted 18 lines

The exynos_tmu_data() function should on entrance test not only for valid data pointer, but also for data->tmu_read one.
It is important, since afterwards it is dereferenced to get temperature code.

---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/thermal/samsung/exynos_tmu.c index 3a19353..a86e0495e 100644

drivers/thermal/samsung/exynos_tmu.c +0 -0
@@ -717,7 +717,7 @@ static int exynos_get_temp(void *p, long *temp)
 {
      struct exynos_tmu_data *data = p;
 
Quoted 7 lines

drivers/thermal/samsung/exynos_tmu.c static int exynos_get_temp(void *p, long *temp) · line 723

Quoted 5 lines
drivers/thermal/samsung/exynos_tmu.c +1 -1
-     if (!data)
+     if (!data || !data->tmu_read)
              return -EINVAL;
 
      mutex_lock(&data->lock);

This fix shall be added to v3.20.

Thanks for looking into this. This fixes the incorrect temperature at boot-up I was seeing on Exynos7 and Exynos5420.

Test HW: Peach-Pit (Exynos5420 based chromebook) and Exynos7 based Espresso board.

Regards,
Abhilash

Quoted 7 lines

--
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group