From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 7 Feb 2007 13:07:08 +0000 (+0100)
Subject: [ALSA] Fix possible deadlocks in sequencer at removal of ports
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6116ea0741abf8f1ef9d93642d985f91c58ff6bf;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git

[ALSA] Fix possible deadlocks in sequencer at removal of ports

Fix possible rwsem deadlocks in sequencer code at removal of
sequencer ports.  The list_lock of port group can be double
locked.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
---

diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c
index d88153438d69..eefd1cf872b4 100644
--- a/sound/core/seq/seq_ports.c
+++ b/sound/core/seq/seq_ports.c
@@ -245,9 +245,9 @@ static void clear_subscriber_list(struct snd_seq_client *client,
 				list_del(&subs->dest_list);
 			else
 				list_del(&subs->src_list);
+			up_write(&agrp->list_mutex);
 			unsubscribe_port(c, aport, agrp, &subs->info, 1);
 			kfree(subs);
-			up_write(&agrp->list_mutex);
 			snd_seq_port_unlock(aport);
 			snd_seq_client_unlock(c);
 		}