Skip to contentSkip to conversation

net: add inline annotation to fix the build warning

PATCH In review Moon Yeounsu 2 participants 3 messages Sep 19, 2024 – Sep 20, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add inline annotation to fix the build warning

This patch fixes two sparse warnings (make C=1):
net/ipv6/icmp.c:103:20: warning: context imbalance in 'icmpv6_xmit_lock' - wrong count at exit net/ipv6/icmp.c:119:13: warning: context imbalance in 'icmpv6_xmit_unlock' - unexpected unlock

Since icmp6_xmit_lock() and icmp6_xmit_unlock() are designed as they are named, entering/returning the function without lock/unlock doesn't matter.

---
 net/ipv6/icmp.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv6/icmp.c +2 -0
index 071b0bc1179d..d8cc3d63c942 100644
@@ -101,6 +101,7 @@ static const struct inet6_protocol icmpv6_protocol = {
 
 /* Called with BH disabled */
 static struct sock *icmpv6_xmit_lock(struct net *net)
+	__acquires(&sk->sk_lock.slock)
 {
 	struct sock *sk;
 
@@ -117,6 +118,7 @@ static struct sock *icmpv6_xmit_lock(struct net *net)
 }
 
 static void icmpv6_xmit_unlock(struct sock *sk)
+	__releases(&sk->sk_lock.slock)
 {
 	sock_net_set(sk, &init_net);
 	spin_unlock(&sk->sk_lock.slock);
Signature · 1 line
2.46.1
reviewer
#1 lore raw
Quoted 9 lines · Moon Yeounsu

This patch fixes two sparse warnings (make C=1):
net/ipv6/icmp.c:103:20: warning: context imbalance in 'icmpv6_xmit_lock' - wrong count at exit net/ipv6/icmp.c:119:13: warning: context imbalance in 'icmpv6_xmit_unlock' - unexpected unlock

Since icmp6_xmit_lock() and icmp6_xmit_unlock() are designed as they are named, entering/returning the function without lock/unlock doesn't matter.

Hi Moon,

Without this patch applied I see the warnings cited above.

However, with this patch applied, I see the following. So I think this needs more work.

net/ipv6/icmp.c: note: in included file (through include/linux/sched.h, include/linux/percpu.h, arch/x86/include/asm/msr.h, arch/x86/include/asm/tsc.h, arch/x86/include/asm/timex.h, include/linux/timex.h, ...):
./include/linux/spinlock.h:361:16: warning: context imbalance in 'icmpv6_xmit_lock' - different lock contexts for basic block
net/ipv6/icmp.c: note: in included file (through include/linux/spinlock.h, include/linux/sched.h, include/linux/percpu.h, arch/x86/include/asm/msr.h, arch/x86/include/asm/tsc.h, arch/x86/include/asm/timex.h, ...):
./include/linux/bottom_half.h:33:30: warning: context imbalance in 'icmp6_send' - different lock contexts for basic block
./include/linux/bottom_half.h:33:30: warning: context imbalance in 'icmpv6_echo_reply' - different lock contexts for basic block

Also, It is my feeling that addressing warnings of this nature is not a fix for net, but rather but rather an enhancement for net-next.

net-next is currently closed for the v6.12 merge windows, so non-RFC, patches should not be posted for net-next until it re-opens once v6.12-rc1 has been released, most likely during the week of 30th September.

Signature · 1 line
pw-bot: changes-requested
#2 lore raw
Quoted 6 lines · Simon Horman

Hi Moon,

Without this patch applied I see the warnings cited above.

However, with this patch applied, I see the following. So I think this needs more work.

Okay, I'll fix and update. (Of course, patch after release -rc1)

Quoted 3 lines

net-next is currently closed for the v6.12 merge windows, so non-RFC, patches should not be posted for net-next until it re-opens once v6.12-rc1 has been released, most likely during the week of 30th September.

Thank you for letting me know : )
During this time, I'll read patches, docs, and code to increase my sense.

I appreciate you reviewing my patch!