Sparse reports a warning
warning: context imbalance in udp_rmem_release() - unexpected unlock
To fix this,
__acquire(&sk_queue->lock) and __release(&sk_queue->lock) annotations
are added in case the condition is not met.
This add basically tell Sparse and not GCC to shutdown the warning
Add __acquire(&sk_queue->lock) annotation
Add the __release(&sk_queue->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/ipv4/udp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5ca12a945ac3..175bd14bfac8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1382,6 +1382,9 @@ static void udp_rmem_release(struct sock *sk, int size, int partial,
sk_queue = &sk->sk_receive_queue;
if (!rx_queue_lock_held)
spin_lock(&sk_queue->lock);
+ else
+ /* annotation for sparse */
+ __acquire(&sk_queue->lock);
sk->sk_forward_alloc += size;
@@ -1398,6 +1401,9 @@ static void udp_rmem_release(struct sock *sk, int size, int partial,
if (!rx_queue_lock_held)
spin_unlock(&sk_queue->lock);
+ else
+ /* annotation for sparse */
+ __release(&sk_queue->lock);
}
/* Note: called with reader_queue.lock held.
--
2.25.3