Skip to content

Commit b5fd12d

Browse files
committed
ALSA: seq: Correct unlock sequence at snd_seq_client_ioctl_unlock()
The doubly unlock sequence at snd_seq_client_ioctl_unlock() is tricky. I took a direct unref call since I thought it would avoid misunderstanding, but rather this seems more confusing. Let's use snd_seq_client_unlock() consistently even if they look strange to be called twice, and add more comments for avoiding reader's confusion. Fixes: 6b580f5 ("ALSA: seq: Protect racy pool manipulation from OSS sequencer") Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 46f5710 commit b5fd12d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎sound/core/seq/seq_clientmgr.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ bool snd_seq_client_ioctl_lock(int clientid)
191191
if (!client)
192192
return false;
193193
mutex_lock(&client->ioctl_mutex);
194+
/* The client isn't unrefed here; see snd_seq_client_ioctl_unlock() */
194195
return true;
195196
}
196197
EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_lock);
@@ -204,7 +205,11 @@ void snd_seq_client_ioctl_unlock(int clientid)
204205
if (WARN_ON(!client))
205206
return;
206207
mutex_unlock(&client->ioctl_mutex);
207-
snd_use_lock_free(&client->use_lock);
208+
/* The doubly unrefs below are intentional; the first one releases the
209+
* leftover from snd_seq_client_ioctl_lock() above, and the second one
210+
* is for releasing snd_seq_client_use_ptr() in this function
211+
*/
212+
snd_seq_client_unlock(client);
208213
snd_seq_client_unlock(client);
209214
}
210215
EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_unlock);

0 commit comments

Comments
 (0)