thermal/drivers/imx: two fixes
Subsystems (2)
cover thermal/drivers/imx: two fixes
---
Felix Gu (2):
thermal/drivers/imx: Fix thermal zone leak on probe error path thermal/drivers/imxl:Fix runtime PM handling on early returns
drivers/thermal/imx_thermal.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
---
base-commit: 66672af7a095d89f082c5327f3b15bc2f93d558e
change-id: 20260411-imx-b022791ea1b9
Best regards,
Signature · 1 line
Felix Gu <[email protected]>
PATCH 1/2 thermal/drivers/imx: Fix thermal zone leak on probe error path
If pm_runtime_resume_and_get() fails after the thermal zone has been registered, the probe error path cleans up runtime PM but skips thermal_zone_device_unregister(), leaking the thermal zone device.
Move thermal_zone_device_unregister() into disable_runtime_pm so all failures after thermal zone registration unwind the probe path correctly.
--- drivers/thermal/imx_thermal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/imx_thermal.c +3 -4
@@ -727,25 +727,24 @@ static int imx_thermal_probe(struct platform_device *pdev) data->irq_enabled = true; ret =thermal_zone_device_enable (data->tz);if (ret) - goto thermal_zone_unregister; + goto disable_runtime_pm; ret =devm_request_threaded_irq (dev, data->irq, imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,0 ,"imx_thermal" , data);if (ret <0 ) {dev_err (dev,"failed to request alarm irq: %d\n" , ret); - goto thermal_zone_unregister; + goto disable_runtime_pm; }pm_runtime_put (data->dev);return 0 ; -thermal_zone_unregister: -thermal_zone_device_unregister (data->tz); disable_runtime_pm:pm_runtime_put_noidle (data->dev);pm_runtime_disable (data->dev); +thermal_zone_device_unregister (data->tz); clk_disable:clk_disable_unprepare (data->thermal_clk); legacy_cleanup:
Signature · 1 line
2.43.0
Frank Li
maintainerRe: [PATCH 1/2] thermal/drivers/imx: Fix thermal zone leak on probe error path
Quoted 5 lines · Felix Gu
If
pm_runtime_resume_and_get()fails after the thermal zone has been registered, the probe error path cleans up runtime PM but skipsthermal_zone_device_unregister(), leaking the thermal zone device.Move
thermal_zone_device_unregister()intodisable_runtime_pmso all
Use devm_thermal_of_zone_register() to fix this problem
Frank
Re: [PATCH 1/2] thermal/drivers/imx: Fix thermal zone leak on probe error path
Quoted 8 lines · Frank Li
Quoted 5 lines · Felix Gu
If
pm_runtime_resume_and_get()fails after the thermal zone has been registered, the probe error path cleans up runtime PM but skipsthermal_zone_device_unregister(), leaking the thermal zone device.Move
thermal_zone_device_unregister()intodisable_runtime_pmso allUse
devm_thermal_of_zone_register()to fix this problem
+1
PATCH 2/2 thermal/drivers/imxl:Fix runtime PM handling on early returns
In reply to Felix GuUse PM_RUNTIME_ACQUIRE() in imx_get_temp() and imx_set_trip_temp() so runtime PM references are released correctly even when the functions return early on errors.
--- drivers/thermal/imx_thermal.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/thermal/imx_thermal.c +6 -8
@@ -260,8 +260,9 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)u32 val;int ret; - ret =pm_runtime_resume_and_get (data->dev); -if (ret <0 ) +PM_RUNTIME_ACQUIRE (data->dev, pm); + ret =PM_RUNTIME_ACQUIRE_ERR (&pm); +if (ret)return ret;regmap_read (map, soc_data->temp_data, &val);
@@ -302,8 +303,6 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)enable_irq (data->irq); } -pm_runtime_put (data->dev); -return 0 ; }
@@ -337,8 +336,9 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,struct imx_thermal_data *data =thermal_zone_device_priv (tz);int ret; - ret =pm_runtime_resume_and_get (data->dev); -if (ret <0 ) +PM_RUNTIME_ACQUIRE (data->dev, pm); + ret =PM_RUNTIME_ACQUIRE_ERR (&pm); +if (ret)return ret;/* do not allow passive to be set higher than critical */
@@ -348,8 +348,6 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,imx_set_alarm_temp (data, temp); trips[IMX_TRIP_PASSIVE ].temperature = temp; -pm_runtime_put (data->dev); -return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] thermal/drivers/imxl:Fix runtime PM handling on early returns
Quoted 6 lines · Felix Gu
Use
PM_RUNTIME_ACQUIRE()inimx_get_temp()andimx_set_trip_temp()so runtime PM references are released correctly even when the functions return early on errors.Fixes 4cf2ddf16e17 ("thermal/drivers/imx: Implement runtime PM support")Signed-off-by Felix Gu <[email protected]>
Quoted 54 lines
--- drivers/thermal/imx_thermal.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/thermal/imx_thermal.c +6
-9@@ -260,8 +260,9 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)u32 val;int ret; - ret =pm_runtime_resume_and_get (data->dev); -if (ret <0 ) +PM_RUNTIME_ACQUIRE (data->dev, pm); + ret =PM_RUNTIME_ACQUIRE_ERR (&pm); +if (ret)return ret;regmap_read (map, soc_data->temp_data, &val);@@ -302,8 +303,6 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)enable_irq (data->irq); } -pm_runtime_put (data->dev); -return 0 ; }@@ -337,8 +336,9 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,struct imx_thermal_data *data =thermal_zone_device_priv (tz);int ret; - ret =pm_runtime_resume_and_get (data->dev); -if (ret <0 ) +PM_RUNTIME_ACQUIRE (data->dev, pm); + ret =PM_RUNTIME_ACQUIRE_ERR (&pm); +if (ret)return ret;/* do not allow passive to be set higher than critical */ @@ -348,8 +348,6 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz,imx_set_alarm_temp (data, temp); trips[IMX_TRIP_PASSIVE ].temperature = temp; -pm_runtime_put (data->dev); -return 0 ; } --2.43.0