git: 91539591d7f8 - main - sound/midi: Drain the mpu401 callout before device teardown

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 13 Nov 2026 11:00:07 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=91539591d7f8dd8ca24ced875bd16c3ba3c7d201

commit 91539591d7f8dd8ca24ced875bd16c3ba3c7d201
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-13 10:59:46 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-13 10:59:46 +0000

    sound/midi: Drain the mpu401 callout before device teardown
    
    midi_uninit() frees the snd_midi that mpu401_intr() reaches through
    midi_in() and midi_out(), but the callout that calls it was drained
    afterwards. Drain it first, and clear M_TXPEND so that a firing handler
    does not re-arm itself.
    
    Fixes:          f960b33d35da ("sound/midi: Drain the mpu401 callout")
    MFC with:       f960b33d35da
    Sponsored by:   The FreeBSD Foundation
---
 sys/dev/sound/midi/mpu401.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/sound/midi/mpu401.c b/sys/dev/sound/midi/mpu401.c
index 20da11216c43..775d1905eeff 100644
--- a/sys/dev/sound/midi/mpu401.c
+++ b/sys/dev/sound/midi/mpu401.c
@@ -154,8 +154,10 @@ int
 mpu401_uninit(struct mpu401 *m)
 {
 	CMD(m, MPU_RESET);
-	midi_uninit(m->mid);
+	/* Clear M_TXPEND so that the callout does not re-arm itself. */
+	m->flags = 0;
 	callout_drain(&m->timer);
+	midi_uninit(m->mid);
 	kobj_delete((kobj_t)m, M_MIDI);
 	return 0;
 }