Skip to content

Commit d21b96c

Browse files
committed
ALSA: mixart: Fix mutex deadlock
The code change for switching to non-atomic mode brought the unexpected mutex deadlock in get_msg(). It converted the spinlock with the existing mutex, but there were calls with the already holding the mutex. Since the only place that needs the extra lock is the code path from snd_mixart_send_msg(), remove the mutex lock in get_msg() and apply in the caller side for fixing the mutex deadlock. Fixes: 8d3a8b5 ("ALSA: mixart: Use nonatomic PCM ops") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201119121440.18945-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 551310e commit d21b96c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

sound/pci/mixart/mixart_core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
7070
unsigned int i;
7171
#endif
7272

73-
mutex_lock(&mgr->msg_lock);
7473
err = 0;
7574

7675
/* copy message descriptor from miXart to driver */
@@ -119,8 +118,6 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
119118
writel_be(headptr, MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD));
120119

121120
_clean_exit:
122-
mutex_unlock(&mgr->msg_lock);
123-
124121
return err;
125122
}
126123

@@ -258,7 +255,9 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
258255
resp.data = resp_data;
259256
resp.size = max_resp_size;
260257

258+
mutex_lock(&mgr->msg_lock);
261259
err = get_msg(mgr, &resp, msg_frame);
260+
mutex_unlock(&mgr->msg_lock);
262261

263262
if( request->message_id != resp.message_id )
264263
dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n");

0 commit comments

Comments
 (0)