]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iavf: fix potential deadlock on allocation failure
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 10 Jul 2023 20:41:27 +0000 (13:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Aug 2023 08:22:33 +0000 (10:22 +0200)
commit1542e399a12ae572ffce413c001344c7734f2bc2
treebdc4e5ac31720fcfc659d66eae6f59921ee7d5ee
parent5a4048355725e439e42cbae4f6e27ed091ba047f
iavf: fix potential deadlock on allocation failure

[ Upstream commit a2f054c10bef0b54600ec9cb776508443e941343 ]

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: fc2e6b3b132a ("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>
drivers/net/ethernet/intel/iavf/iavf_main.c