Skip to content

Commit a2f054c

Browse files
jacob-kelleranguy11
authored andcommitted
iavf: fix potential deadlock on allocation failure
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: fc2e6b3 ("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>
1 parent 043b1f1 commit a2f054c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,7 @@ static void iavf_adminq_task(struct work_struct *work)
32643264
event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
32653265
event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
32663266
if (!event.msg_buf)
3267-
goto out;
3267+
goto unlock;
32683268

32693269
do {
32703270
ret = iavf_clean_arq_element(hw, &event, &pending);
@@ -3279,7 +3279,6 @@ static void iavf_adminq_task(struct work_struct *work)
32793279
if (pending != 0)
32803280
memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
32813281
} while (pending);
3282-
mutex_unlock(&adapter->crit_lock);
32833282

32843283
if (iavf_is_reset_in_progress(adapter))
32853284
goto freedom;
@@ -3323,6 +3322,8 @@ static void iavf_adminq_task(struct work_struct *work)
33233322

33243323
freedom:
33253324
kfree(event.msg_buf);
3325+
unlock:
3326+
mutex_unlock(&adapter->crit_lock);
33263327
out:
33273328
/* re-enable Admin queue interrupt cause */
33283329
iavf_misc_irq_enable(adapter);

0 commit comments

Comments
 (0)