Skip to contentSkip to conversation

ALSA: seq: Fix port lock leak in deliver_to_subscribers()

PATCH In review Tzung-Bi Shih 3 participants 4 messages Sep 4 – Sep 8 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: seq: Fix port lock leak in deliver_to_subscribers()

Commit 46397622a3fa ("ALSA: seq: Add UMP support") mistakenly removed the snd_seq_port_unlock(src_port) call in deliver_to_subscribers(). As a result, every time an event is delivered to a subscriber, the source port's use_lock atomic counter is increased but never decreased.

The leak prevents ALSA sequencer ports from closing cleanly. When the client process exits or destroys the port, port_delete() hangs forever at snd_use_lock_sync(). The process becomes stuck in an unkillable D state, triggering the following warning:

ALSA: seq_lock: waiting [1 left] in sound/core/seq/seq_ports.c:250

Restore the missing snd_seq_port_unlock(src_port).

Note that commit 177ccf811df4 ("ALSA: seq: Support MIDI 2.0 UMP Endpoint port") incidentally resolved this issue upstream when it refactored the locking logic into a wrapper function. However, since the commit introduces a new feature and might not be suitable for stable release branches, this targeted fix is necessary.

Fixes 6389f2c13531 ("ALSA: seq: Add UMP support")
---
 sound/core/seq/seq_clientmgr.c | 1 +
 1 file changed, 1 insertion(+)
sound/core/seq/seq_clientmgr.c +1 -0
index f2feeb97765c..bd2d7a9fab5b 100644
@@ -733,6 +733,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
 		read_unlock(&grp->list_lock);
 	else
 		up_read(&grp->list_mutex);
+	snd_seq_port_unlock(src_port);
 	memcpy(event, &event_saved, saved_size);
 	return (result < 0) ? result : num_ev;
 }
Signature · 1 line
2.55.0.979.g7e5102b832-goog
maintainer
#1 lore raw
Quoted 4 lines

Commit 46397622a3fa ("ALSA: seq: Add UMP support") mistakenly removed the snd_seq_port_unlock(src_port) call in deliver_to_subscribers(). As a result, every time an event is delivered to a subscriber, the source port's use_lock atomic counter is increased but never

The fix itself looks right - restores exactly the unlock that 46397622a3fa dropped, nothing else touched. But there's no mainline commit backing it (the actual upstream fix would be 177ccf811df4, which is a MIDI 2.0 feature commit and not stable material on its own), so this is a stable-only fix and needs a subsystem Ack before it can go in.

Jaroslav, Takashi - can either of you Ack this for 5.15.y?

Signature · 2 lines
Thanks,
Sasha
Reviewed-by
#2 lore raw
Quoted 6 lines · Sasha Levin
Quoted 5 lines

Commit 46397622a3fa ("ALSA: seq: Add UMP support") mistakenly removed the snd_seq_port_unlock(src_port) call in deliver_to_subscribers(). As a result, every time an event is delivered to a subscriber, the source port's use_lock atomic counter is increased but never

Quoted 7 lines

The fix itself looks right - restores exactly the unlock that 46397622a3fa dropped, nothing else touched. But there's no mainline commit backing it (the actual upstream fix would be 177ccf811df4, which is a MIDI 2.0 feature commit and not stable material on its own), so this is a stable-only fix and needs a subsystem Ack before it can go in.

Jaroslav, Takashi - can either of you Ack this for 5.15.y?

thanks,

Takashi