]> www.infradead.org Git - users/jedix/linux-maple.git/commit
thermal/drivers/broadcom: Fix race between removal and clock disable
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 9 Jul 2024 12:59:31 +0000 (14:59 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 15 Jul 2024 11:31:40 +0000 (13:31 +0200)
commite90c369cc2ffcf7145a46448de101f715a1f5584
treebca0c199eca6982a8b74aafdd00fc7967cb3d2eb
parent6f48290b1a18dba5870920188725eee6fe603ee6
thermal/drivers/broadcom: Fix race between removal and clock disable

During the probe, driver enables clocks necessary to access registers
(in get_temp()) and then registers thermal zone with managed-resources
(devm) interface.  Removal of device is not done in reversed order,
because:
1. Clock will be disabled in driver remove() callback - thermal zone is
   still registered and accessible to users,
2. devm interface will unregister thermal zone.

This leaves short window between (1) and (2) for accessing the
get_temp() callback with disabled clock.

Fix this by enabling clock also via devm-interface, so entire cleanup
path will be in proper, reversed order.

Fixes: 8454c8c09c77 ("thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister")
Cc: stable@vger.kernel.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240709-thermal-probe-v1-1-241644e2b6e0@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/broadcom/bcm2835_thermal.c