diff mbox

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

Message ID 1423228030-18708-1-git-send-email-l.majewski@samsung.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Lukasz Majewski Feb. 6, 2015, 1:07 p.m. UTC
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.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lukasz Majewski Feb. 16, 2015, 9:53 a.m. UTC | #1
Hi Eduardo,

> 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.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/thermal/samsung/exynos_tmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c
> b/drivers/thermal/samsung/exynos_tmu.c index 3a19353..a86e0495e 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -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.
Abhilash Kesavan Feb. 19, 2015, 12:23 p.m. UTC | #2
Hi Lukasz,

On Mon, Feb 16, 2015 at 3:23 PM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Eduardo,
>
>> 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.
>>
>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>> ---
>>  drivers/thermal/samsung/exynos_tmu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/samsung/exynos_tmu.c
>> b/drivers/thermal/samsung/exynos_tmu.c index 3a19353..a86e0495e 100644
>> --- a/drivers/thermal/samsung/exynos_tmu.c
>> +++ b/drivers/thermal/samsung/exynos_tmu.c
>> @@ -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.

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

Tested-by: Abhilash Kesavan <a.kesavan@samsung.com>

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

Regards,
Abhilash
>
> --
> Best regards,
>
> Lukasz Majewski
>
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 3a19353..a86e0495e 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -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);