[PATCH 3.16 116/305] thermal: rcar_thermal: Prevent doing work after unbind

From: Ben Hutchings
Date: Sun Feb 03 2019 - 09:01:36 EST


3.16.63-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

commit 697ee786f15d7b65c7f3045d45fe3a05d28e0911 upstream.

When testing bind/unbind on r8a7791/koelsch:

WARNING: CPU: 1 PID: 697 at lib/debugobjects.c:329 debug_print_object+0x8c/0xb4
ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x10

This happens if the workqueue runs after the device has been unbound.
Fix this by cancelling any queued work during remove.

Fixes: e0a5172e9eec7f0d ("thermal: rcar: add interrupt support")
Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
Reviewed-by: Niklas SÃderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
Signed-off-by: Eduardo Valentin <edubezval@xxxxxxxxx>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/thermal/rcar_thermal.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -464,6 +464,7 @@ error_unregister:
rcar_thermal_for_each_priv(priv, common) {
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
+ cancel_delayed_work_sync(&priv->work);
thermal_zone_device_unregister(priv->zone);
}