ALSA: seq: Fix port lock leak in deliver_to_subscribers()
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.
--- sound/core/seq/seq_clientmgr.c | 1 + 1 file changed, 1 insertion(+)
sound/core/seq/seq_clientmgr.c +1 -0
@@ -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
Sasha Levin
maintainerQuoted 4 lines
Commit
46397622a3fa("ALSA: seq: Add UMP support") mistakenly removed thesnd_seq_port_unlock(src_port)call indeliver_to_subscribers(). As a result, every time an event is delivered to a subscriber, the source port'suse_lockatomic 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
Takashi Iwai
Reviewed-byQuoted 6 lines · Sasha Levin
Quoted 5 lines
Commit
46397622a3fa("ALSA: seq: Add UMP support") mistakenly removed thesnd_seq_port_unlock(src_port)call indeliver_to_subscribers(). As a result, every time an event is delivered to a subscriber, the source port'suse_lockatomic counter is increased but never
Quoted 7 lines
The fix itself looks right - restores exactly the unlock that
46397622a3fadropped, nothing else touched. But there's no mainline commit backing it (the actual upstream fix would be177ccf811df4, 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
Sasha Levin
maintainerQuoted 1 line
Reviewed-by Takashi Iwai <[email protected]>
Thanks for the ack. Queued for 5.15.
Signature · 2 lines
Thanks, Sasha