git: 961e18b07cda - main - sound/midi: Do not return from midi_close() with the lock held

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 16:38:09 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=961e18b07cda24e838098127e1079372851379df

commit 961e18b07cda24e838098127e1079372851379df
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-10 14:03:53 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-12 16:35:49 +0000

    sound/midi: Do not return from midi_close() with the lock held
    
    This was already fixed in midi_open().
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 sys/dev/sound/midi/midi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
index 6561bd8a6f52..dbec096e3f66 100644
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -367,9 +367,10 @@ midi_close(struct cdev *i_dev, int flags, int mode, struct thread *td)
 	if ((m->flags & (M_TXEN | M_RXEN)) != (oldflags & (M_RXEN | M_TXEN)))
 		MPU_CALLBACK(m, m->cookie, m->flags);
 
-	mtx_unlock(&m->lock);
 	retval = 0;
-err:	return retval;
+err:
+	mtx_unlock(&m->lock);
+	return retval;
 }
 
 /*