ASoC: rt5645: Shut down the button timer on removal
Subsystems (3)
PATCH 1/1 ASoC: rt5645: Shut down the button timer on removal
jack_detect_work can rearm btn_check_timer, and the timer callback can queue jack_detect_work. Deleting the timer before cancelling the work does not break this cycle: an already running worker can rearm the timer after timer_delete_sync() returns. The timer can then outlive removal.
Use timer_shutdown_sync() before cancelling the delayed work so that subsequent attempts to rearm the timer are ignored. The IRQ producer has already been removed at this point. Keep the restartable timer deletion in the suspend path.
This issue was identified as part of our ongoing research while reviewing kernel code.
---
Compile-tested with GCC, W=1 (x86_64). No runtime testing.
sound/soc/codecs/rt5645.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/codecs/rt5645.c +4 -3
@@ -19,6 +19,7 @@#include <linux/acpi.h> #include <linux/dmi.h> #include <linux/regulator/consumer.h> +#include <linux/timer.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -4292,10 +4293,10 @@ static void rt5645_i2c_remove(struct i2c_client *i2c)free_irq (i2c->irq, rt5645);/* -* Since the rt5645_btn_check_callback() can queue jack_detect_work, -* the timer need to be delted first +* The timer and jack_detect_work can rearm each other. Shut down the +* timer before cancelling the work. */ -timer_delete_sync (&rt5645->btn_check_timer); +timer_shutdown_sync (&rt5645->btn_check_timer);cancel_delayed_work_sync (&rt5645->jack_detect_work);cancel_delayed_work_sync (&rt5645->rcclock_work);
Mark Brown
maintainerQuoted 1 line · Myeonghun Pak
ASoC: rt5645: Shut down the button timer on removal
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: rt5645: Shut down the button timer on removal
https://git.kernel.org/broonie/sound/c/f0ecc305442f
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark