mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
iavf: fix potential deadlock on allocation failure
[ Upstream commita2f054c10b] In iavf_adminq_task(), if kzalloc() fails to allocate the event.msg_buf, the function will exit without releasing the adapter->crit_lock. This is unlikely, but if it happens, the next access to that mutex will deadlock. Fix this by moving the unlock to the end of the function, and adding a new label to allow jumping to the unlock portion of the function exit flow. Fixes:fc2e6b3b13("iavf: Rework mutexes for better synchronisation") Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c0fa9a5a7a
commit
469879eda3
@@ -3300,7 +3300,7 @@ static void iavf_adminq_task(struct work_struct *work)
|
|||||||
event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
|
event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
|
||||||
event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
|
event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
|
||||||
if (!event.msg_buf)
|
if (!event.msg_buf)
|
||||||
goto out;
|
goto unlock;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = iavf_clean_arq_element(hw, &event, &pending);
|
ret = iavf_clean_arq_element(hw, &event, &pending);
|
||||||
@@ -3315,7 +3315,6 @@ static void iavf_adminq_task(struct work_struct *work)
|
|||||||
if (pending != 0)
|
if (pending != 0)
|
||||||
memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
|
memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
|
||||||
} while (pending);
|
} while (pending);
|
||||||
mutex_unlock(&adapter->crit_lock);
|
|
||||||
|
|
||||||
if (iavf_is_reset_in_progress(adapter))
|
if (iavf_is_reset_in_progress(adapter))
|
||||||
goto freedom;
|
goto freedom;
|
||||||
@@ -3359,6 +3358,8 @@ static void iavf_adminq_task(struct work_struct *work)
|
|||||||
|
|
||||||
freedom:
|
freedom:
|
||||||
kfree(event.msg_buf);
|
kfree(event.msg_buf);
|
||||||
|
unlock:
|
||||||
|
mutex_unlock(&adapter->crit_lock);
|
||||||
out:
|
out:
|
||||||
/* re-enable Admin queue interrupt cause */
|
/* re-enable Admin queue interrupt cause */
|
||||||
iavf_misc_irq_enable(adapter);
|
iavf_misc_irq_enable(adapter);
|
||||||
|
|||||||
Reference in New Issue
Block a user