Thread (4 messages) flat view 4 messages, 3 authors, 2025-07-01

Re: [PATCH] nfp: nfp_alloc_bar: Fix double unlock

From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-06-23 20:11:42
Also in: lkml

On Mon, 23 Jun 2025 12:11:04 +0800 WangYuli wrote:
The lock management in the nfp_alloc_bar function is problematic:

 *1. The function acquires the lock at the beginning:
spin_lock_irqsave(&nfp->bar_lock, irqflags).

  2. When barnum < 0 and in non-blocking mode, the code jumps to
the err_nobar label. However, in this non-blocking path, if
barnum < 0, the code releases the lock and calls nfp_wait_for_bar.

  3. Inside nfp_wait_for_bar, find_unused_bar_and_lock is called,
which holds the lock upon success (indicated by the __release
annotation). Consequently, when nfp_wait_for_bar returns
successfully, the lock is still held.

  4. But at the err_nobar label, the code always executes
spin_unlock_irqrestore(&nfp->bar_lock, irqflags).

  5. The problem arises when nfp_wait_for_bar successfully finds a
BAR: the lock is still held, but if a subsequent reconfigure_bar
fails, the code will attempt to unlock it again at err_nobar,
leading to a double unlock.
I don't understand what you're trying to say.
If you think your analysis is correct please provide a more exact
execution path with a code listing.
-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help