Thread (1 message) 1 message, 1 author, 2020-04-29

[PATCH 3/6] udp: Add annotations for udp_rmem_release()

DORMANTno replies

From: Jules Irenge <hidden>
Date: 2020-04-29 10:07:10
Also in: lkml
Subsystem: networking [general], the rest, user datagram protocol (udp) · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Willem de Bruijn

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help