Commit a2ff19f7 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: seq: Clear client entry before deleting else at closing

When releasing a client, we need to clear the clienttab[] entry at
first, then call snd_seq_queue_client_leave().  Otherwise, the
in-flight cell in the queue might be picked up by the timer interrupt
via snd_seq_check_queue() before calling snd_seq_queue_client_leave(),
and it's delivered to another queue while the client is clearing
queues.  This may eventually result in an uncleared cell remaining in
a queue, and the later snd_seq_pool_delete() may need to wait for a
long time until the event gets really processed.

By moving the clienttab[] clearance at the beginning of release, any
event delivery of a cell belonging to this client will fail at a later
point, since snd_seq_client_ptr() returns NULL.  Thus the cell that
was picked up by the timer interrupt will be returned immediately
without further delivery, and the long stall of snd_seq_delete_pool()
can be avoided, too.

Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d0f83306
...@@ -255,12 +255,12 @@ static int seq_free_client1(struct snd_seq_client *client) ...@@ -255,12 +255,12 @@ static int seq_free_client1(struct snd_seq_client *client)
if (!client) if (!client)
return 0; return 0;
snd_seq_delete_all_ports(client);
snd_seq_queue_client_leave(client->number);
spin_lock_irqsave(&clients_lock, flags); spin_lock_irqsave(&clients_lock, flags);
clienttablock[client->number] = 1; clienttablock[client->number] = 1;
clienttab[client->number] = NULL; clienttab[client->number] = NULL;
spin_unlock_irqrestore(&clients_lock, flags); spin_unlock_irqrestore(&clients_lock, flags);
snd_seq_delete_all_ports(client);
snd_seq_queue_client_leave(client->number);
snd_use_lock_sync(&client->use_lock); snd_use_lock_sync(&client->use_lock);
snd_seq_queue_client_termination(client->number); snd_seq_queue_client_termination(client->number);
if (client->pool) if (client->pool)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment