From f423ab17d3e196d9694cb6744000610a0af02ad2 Mon Sep 17 00:00:00 2001 From: Xiaoyu Ye Date: Wed, 22 Nov 2017 11:38:29 -0800 Subject: [PATCH] dsp: unlock the mutex before return to avoid potential deadlock Function "q6asm_set_shared_circ_buff" has a potential scenario that can cause deadlock due to a missing call to unlock mutex before return. Avoid this potential deadlock by calling the mutex unlock just before the return of function "q6asm_set_shared_circ_buff". Change-Id: Ic454eb5eb57c7616d891277c09e0e3bd37e63cd2 Signed-off-by: Xiaoyu Ye --- dsp/q6asm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dsp/q6asm.c b/dsp/q6asm.c index 4e988ee489e6..ba6bbb6766eb 100644 --- a/dsp/q6asm.c +++ b/dsp/q6asm.c @@ -3541,7 +3541,6 @@ int q6asm_set_shared_circ_buff(struct audio_client *ac, if (ac->port[dir].buf) { pr_err("%s: Buffer already allocated\n", __func__); rc = -EINVAL; - mutex_unlock(&ac->cmd_lock); goto done; } @@ -3564,7 +3563,6 @@ int q6asm_set_shared_circ_buff(struct audio_client *ac, pr_err("%s: Audio ION alloc is failed, rc = %d\n", __func__, rc); kfree(buf_circ); - mutex_unlock(&ac->cmd_lock); goto done; } @@ -3590,8 +3588,8 @@ int q6asm_set_shared_circ_buff(struct audio_client *ac, msm_audio_populate_upper_32_bits(buf_circ->phys); open->map_region_circ_buf.mem_size_bytes = bytes_to_alloc; - mutex_unlock(&ac->cmd_lock); done: + mutex_unlock(&ac->cmd_lock); return rc; }