diff mbox series

thermal/drivers/exynos: Fix NULL pointer dereference when getting the critical temp

Message ID 20221003132943.1383065-1-daniel.lezcano@linaro.org (mailing list archive)
State New, archived
Headers show
Series thermal/drivers/exynos: Fix NULL pointer dereference when getting the critical temp | expand

Commit Message

Daniel Lezcano Oct. 3, 2022, 1:29 p.m. UTC
The driver is assuming the get_critical temperature exists as it is
inherited by the thermal of ops. But this one has been removed in
favor of the generic one.

Use the generic thermal_zone_get_crit_temp() function instead

Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/samsung/exynos_tmu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Krzysztof Kozlowski Oct. 3, 2022, 1:40 p.m. UTC | #1
On 03/10/2022 15:29, Daniel Lezcano wrote:
> The driver is assuming the get_critical temperature exists as it is
> inherited by the thermal of ops. But this one has been removed in
> favor of the generic one.
> 
> Use the generic thermal_zone_get_crit_temp() function instead
> 
> Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Looks good.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
Marek Szyprowski Oct. 3, 2022, 1:50 p.m. UTC | #2
On 03.10.2022 15:29, Daniel Lezcano wrote:
> The driver is assuming the get_critical temperature exists as it is
> inherited by the thermal of ops. But this one has been removed in
> favor of the generic one.
>
> Use the generic thermal_zone_get_crit_temp() function instead
>
> Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>   drivers/thermal/samsung/exynos_tmu.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 5a1ffe2f3134..37465af59262 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -264,9 +264,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
>   	unsigned int status;
>   	int ret = 0, temp;
>   
> -	if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
> -		ret = tzd->ops->get_crit_temp(tzd, &temp);
> -	if (ret) {
> +	ret = thermal_zone_get_crit_temp(tzd, &temp);
> +	if (ret && data->soc != SOC_ARCH_EXYNOS5433) { /* FIXME */
>   		dev_err(&pdev->dev,
>   			"No CRITICAL trip point defined in device tree!\n");
>   		goto out;

Best regards
Marek Szyprowski Oct. 17, 2022, 1:48 p.m. UTC | #3
Hi Daniel,

On 03.10.2022 15:29, Daniel Lezcano wrote:
> The driver is assuming the get_critical temperature exists as it is
> inherited by the thermal of ops. But this one has been removed in
> favor of the generic one.
>
> Use the generic thermal_zone_get_crit_temp() function instead
>
> Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

This patch has been dropped from -next, is there are reason for that?


> ---
>   drivers/thermal/samsung/exynos_tmu.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 5a1ffe2f3134..37465af59262 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -264,9 +264,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
>   	unsigned int status;
>   	int ret = 0, temp;
>   
> -	if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
> -		ret = tzd->ops->get_crit_temp(tzd, &temp);
> -	if (ret) {
> +	ret = thermal_zone_get_crit_temp(tzd, &temp);
> +	if (ret && data->soc != SOC_ARCH_EXYNOS5433) { /* FIXME */
>   		dev_err(&pdev->dev,
>   			"No CRITICAL trip point defined in device tree!\n");
>   		goto out;

Best regards
Daniel Lezcano Oct. 17, 2022, 2:14 p.m. UTC | #4
On 17/10/2022 15:48, Marek Szyprowski wrote:
> Hi Daniel,
> 
> On 03.10.2022 15:29, Daniel Lezcano wrote:
>> The driver is assuming the get_critical temperature exists as it is
>> inherited by the thermal of ops. But this one has been removed in
>> favor of the generic one.
>>
>> Use the generic thermal_zone_get_crit_temp() function instead
>>
>> Fixes: 13bea86623b ("thermal/of: Remove of_thermal_get_crit_temp(")
>> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> This patch has been dropped from -next, is there are reason for that?

No, my mistake. I dropped it accidentally when I rebased the branch.

Thanks for pointing it out.
diff mbox series

Patch

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 5a1ffe2f3134..37465af59262 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -264,9 +264,8 @@  static int exynos_tmu_initialize(struct platform_device *pdev)
 	unsigned int status;
 	int ret = 0, temp;
 
-	if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
-		ret = tzd->ops->get_crit_temp(tzd, &temp);
-	if (ret) {
+	ret = thermal_zone_get_crit_temp(tzd, &temp);
+	if (ret && data->soc != SOC_ARCH_EXYNOS5433) { /* FIXME */
 		dev_err(&pdev->dev,
 			"No CRITICAL trip point defined in device tree!\n");
 		goto out;