Skip to content

Commit 8454c8c

Browse files
committed
thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister
The driver is using the devm_thermal_of_zone_device_register(). In the error path of the function calling devm_thermal_of_zone_device_register(), the function devm_thermal_of_zone_unregister() should be called instead of thermal_of_zone_unregister(), otherwise this one will be called twice when the device is freed. The same happens for the remove function where the devm_ guarantee the thermal_of_zone_unregister() will be called, so adding this call in the remove function will lead to a double free also. Use devm_ variant in the error path of the probe function. Remove thermal_of_zone_unregister() in the remove function. Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ray Jui <rjui@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230404075138.2914680-1-daniel.lezcano@linaro.org
1 parent 561538f commit 8454c8c

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/thermal/broadcom/bcm2835_thermal.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
275275

276276
return 0;
277277
err_tz:
278-
thermal_of_zone_unregister(tz);
278+
devm_thermal_of_zone_unregister(&pdev->dev, tz);
279279
err_clk:
280280
clk_disable_unprepare(data->clk);
281281

@@ -285,10 +285,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
285285
static int bcm2835_thermal_remove(struct platform_device *pdev)
286286
{
287287
struct bcm2835_thermal_data *data = platform_get_drvdata(pdev);
288-
struct thermal_zone_device *tz = data->tz;
289288

290289
debugfs_remove_recursive(data->debugfsdir);
291-
thermal_of_zone_unregister(tz);
292290
clk_disable_unprepare(data->clk);
293291

294292
return 0;

0 commit comments

Comments
 (0)