Commit b09a456
committed
hwmon: (lm90) Stop work before releasing hwmon device
Sashiko reports:
In lm90_probe(), the devm action to cancel the alert_work and report_work
(lm90_restore_conf) is registered in lm90_init_client() before
devm_hwmon_device_register_with_info() is called.
Because devm executes cleanup actions in reverse order during module
unbind or probe failure, the hwmon device is unregistered and freed first.
If lm90_alert_work() or lm90_report_alarms() runs in the window between
the hwmon device being freed and the delayed works being cancelled,
lm90_update_alarms() will dereference the freed data->hwmon_dev here.
Fix the problem by canceling the workers separately after registering
the hwmon device and before registering the interrupt handler. This ensures
that the workers are canceled after interrupts are disabled and before
the hwmon device is released. Add "shutdown" flag to indicate that device
shutdown is in progress to prevent workers from being re-armed.
Fixes: f6d0775 ("hwmon: (lm90) Rework alarm/status handling")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>1 parent 51f5760 commit b09a456
1 file changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
| |||
1154 | 1155 | | |
1155 | 1156 | | |
1156 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
1157 | 1161 | | |
1158 | 1162 | | |
1159 | 1163 | | |
| |||
2584 | 2588 | | |
2585 | 2589 | | |
2586 | 2590 | | |
2587 | | - | |
2588 | | - | |
2589 | | - | |
2590 | 2591 | | |
2591 | 2592 | | |
2592 | 2593 | | |
2593 | 2594 | | |
2594 | 2595 | | |
2595 | 2596 | | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
2596 | 2608 | | |
2597 | 2609 | | |
2598 | 2610 | | |
| |||
2902 | 2914 | | |
2903 | 2915 | | |
2904 | 2916 | | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
2905 | 2921 | | |
2906 | 2922 | | |
2907 | 2923 | | |
| |||
2930 | 2946 | | |
2931 | 2947 | | |
2932 | 2948 | | |
2933 | | - | |
| 2949 | + | |
2934 | 2950 | | |
2935 | 2951 | | |
2936 | 2952 | | |
| |||
0 commit comments