Skip to content

Commit

Permalink
thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Daniel Lezcano committed Apr 7, 2023
1 parent 561538f commit 8454c8c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/thermal/broadcom/bcm2835_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)

return 0;
err_tz:
thermal_of_zone_unregister(tz);
devm_thermal_of_zone_unregister(&pdev->dev, tz);
err_clk:
clk_disable_unprepare(data->clk);

Expand All @@ -285,10 +285,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
static int bcm2835_thermal_remove(struct platform_device *pdev)
{
struct bcm2835_thermal_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tz;

debugfs_remove_recursive(data->debugfsdir);
thermal_of_zone_unregister(tz);
clk_disable_unprepare(data->clk);

return 0;
Expand Down

0 comments on commit 8454c8c

Please sign in to comment.