* [PATCH] thermal: exynos_tmu: avoid uninitialized variables
@ 2018-03-28 13:44 ` Arnd Bergmann
2018-03-28 13:56 ` Bartlomiej Zolnierkiewicz
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-03-28 13:44 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz, Zhang Rui, Eduardo Valentin,
Kukjin Kim, Krzysztof Kozlowski
Cc: linux-samsung-soc, Arnd Bergmann, linux-pm, linux-kernel,
Maciej Purski, linux-arm-kernel, Marek Szyprowski
Removing the initialization in the error case introduced
a compile-time warning:
drivers/thermal/samsung/exynos_tmu.c: In function 'temp_to_code':
drivers/thermal/samsung/exynos_tmu.c:304:9: error: 'temp_code' may be used uninitialized in this function [-Werror=maybe-uninitialized]
return temp_code;
^~~~~~~~~
drivers/thermal/samsung/exynos_tmu.c: In function 'exynos_get_temp':
drivers/thermal/samsung/exynos_tmu.c:931:37: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
*temp = code_to_temp(data, value) * MCELSIUS;
Let's assume the runtime warning is sufficient, and make it
return a well-defined number instead of unintialized data.
Fixes: 480b5bfc16e1 ("thermal: exynos: remove parsing of samsung, tmu_default_temp_offset property")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/thermal/samsung/exynos_tmu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2ec854851da1..7e351fffdaee 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -298,6 +298,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
break;
default:
WARN_ON(1);
+ temp_code = 0;
break;
}
@@ -324,6 +325,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
break;
default:
WARN_ON(1);
+ temp = 0;
break;
}
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thermal: exynos_tmu: avoid uninitialized variables
2018-03-28 13:44 ` [PATCH] thermal: exynos_tmu: avoid uninitialized variables Arnd Bergmann
@ 2018-03-28 13:56 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:56 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Zhang Rui, Eduardo Valentin, Kukjin Kim, Krzysztof Kozlowski,
Marek Szyprowski, Maciej Purski, linux-pm, linux-samsung-soc,
linux-arm-kernel, linux-kernel
On Wednesday, March 28, 2018 03:44:44 PM Arnd Bergmann wrote:
> Removing the initialization in the error case introduced
> a compile-time warning:
>
> drivers/thermal/samsung/exynos_tmu.c: In function 'temp_to_code':
> drivers/thermal/samsung/exynos_tmu.c:304:9: error: 'temp_code' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> return temp_code;
> ^~~~~~~~~
> drivers/thermal/samsung/exynos_tmu.c: In function 'exynos_get_temp':
> drivers/thermal/samsung/exynos_tmu.c:931:37: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> *temp = code_to_temp(data, value) * MCELSIUS;
>
> Let's assume the runtime warning is sufficient, and make it
> return a well-defined number instead of unintialized data.
>
> Fixes: 480b5bfc16e1 ("thermal: exynos: remove parsing of samsung, tmu_default_temp_offset property")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks Arnd!
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-28 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20180328134538epcas2p4bb7a1f273824995e4baeb10d9563ffda@epcas2p4.samsung.com>
2018-03-28 13:44 ` [PATCH] thermal: exynos_tmu: avoid uninitialized variables Arnd Bergmann
2018-03-28 13:56 ` Bartlomiej Zolnierkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).