Re: [PATCH] ALSA: mpu401: shut down timer before freeing MPU
From: Takashi Iwai
Date: Mon Sep 28 2026 - 09:08:53 EST
On Sun, 27 Sep 2026 11:38:09 +0200,
Runyu Xiao wrote:
>
> When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI
> input and output with a timer. During raw-MIDI teardown, the timer callback
> can already be running when snd_mpu401_uart_remove_timer() clears the last
> mode bit and calls timer_delete(). That API neither waits for a running
> callback nor prevents it from rearming the timer, and free_irq() does not
> synchronize timer callbacks. snd_mpu401_uart_free() can therefore release
> mpu while the timer callback still uses it.
>
> Initialize the timer once when the MPU object is created and only rearm it
> while a timer mode is active. Shut it down synchronously after freeing the
> IRQ so an in-flight callback completes before mpu and its resources are
> released.
>
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
Applied to for-next branch. Thanks.
Takashi