Skip to content

Commit 9a429c4

Browse files
Eric Dumazetdavem330
authored andcommitted
[NET]: Add some acquires/releases sparse annotations.
Add __acquires() and __releases() annotations to suppress some sparse warnings. example of warnings : net/ipv4/udp.c:1555:14: warning: context imbalance in 'udp_seq_start' - wrong count at exit net/ipv4/udp.c:1571:13: warning: context imbalance in 'udp_seq_stop' - unexpected unlock Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b950dfc commit 9a429c4

16 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎net/core/dev.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,7 @@ static int dev_ifconf(struct net *net, char __user *arg)
23682368
* in detail.
23692369
*/
23702370
void *dev_seq_start(struct seq_file *seq, loff_t *pos)
2371+
__acquires(dev_base_lock)
23712372
{
23722373
struct net *net = seq_file_net(seq);
23732374
loff_t off;
@@ -2394,6 +2395,7 @@ void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
23942395
}
23952396

23962397
void dev_seq_stop(struct seq_file *seq, void *v)
2398+
__releases(dev_base_lock)
23972399
{
23982400
read_unlock(&dev_base_lock);
23992401
}

‎net/core/dev_mcast.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ EXPORT_SYMBOL(dev_mc_unsync);
186186

187187
#ifdef CONFIG_PROC_FS
188188
static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
189+
__acquires(dev_base_lock)
189190
{
190191
struct net *net = seq_file_net(seq);
191192
struct net_device *dev;
@@ -206,6 +207,7 @@ static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
206207
}
207208

208209
static void dev_mc_seq_stop(struct seq_file *seq, void *v)
210+
__releases(dev_base_lock)
209211
{
210212
read_unlock(&dev_base_lock);
211213
}

‎net/core/gen_stats.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size)
5555
int
5656
gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
5757
int xstats_type, spinlock_t *lock, struct gnet_dump *d)
58+
__acquires(lock)
5859
{
5960
memset(d, 0, sizeof(*d));
6061

‎net/core/neighbour.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,7 @@ static void *neigh_get_idx_any(struct seq_file *seq, loff_t *pos)
23132313
}
23142314

23152315
void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl, unsigned int neigh_seq_flags)
2316+
__acquires(tbl->lock)
23162317
{
23172318
struct neigh_seq_state *state = seq->private;
23182319
loff_t pos_minus_one;
@@ -2356,6 +2357,7 @@ void *neigh_seq_next(struct seq_file *seq, void *v, loff_t *pos)
23562357
EXPORT_SYMBOL(neigh_seq_next);
23572358

23582359
void neigh_seq_stop(struct seq_file *seq, void *v)
2360+
__releases(tbl->lock)
23592361
{
23602362
struct neigh_seq_state *state = seq->private;
23612363
struct neigh_table *tbl = state->tbl;

‎net/core/sock.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,7 @@ EXPORT_SYMBOL(proto_unregister);
20252025

20262026
#ifdef CONFIG_PROC_FS
20272027
static void *proto_seq_start(struct seq_file *seq, loff_t *pos)
2028+
__acquires(proto_list_lock)
20282029
{
20292030
read_lock(&proto_list_lock);
20302031
return seq_list_start_head(&proto_list, *pos);
@@ -2036,6 +2037,7 @@ static void *proto_seq_next(struct seq_file *seq, void *v, loff_t *pos)
20362037
}
20372038

20382039
static void proto_seq_stop(struct seq_file *seq, void *v)
2040+
__releases(proto_list_lock)
20392041
{
20402042
read_unlock(&proto_list_lock);
20412043
}

‎net/ipv4/fib_hash.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos)
936936
}
937937

938938
static void *fib_seq_start(struct seq_file *seq, loff_t *pos)
939+
__acquires(fib_hash_lock)
939940
{
940941
void *v = NULL;
941942

@@ -952,6 +953,7 @@ static void *fib_seq_next(struct seq_file *seq, void *v, loff_t *pos)
952953
}
953954

954955
static void fib_seq_stop(struct seq_file *seq, void *v)
956+
__releases(fib_hash_lock)
955957
{
956958
read_unlock(&fib_hash_lock);
957959
}

‎net/ipv4/inet_hashtables.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ EXPORT_SYMBOL(inet_put_port);
9696
* exclusive lock release). It should be ifdefed really.
9797
*/
9898
void inet_listen_wlock(struct inet_hashinfo *hashinfo)
99+
__acquires(hashinfo->lhash_lock)
99100
{
100101
write_lock(&hashinfo->lhash_lock);
101102

‎net/ipv4/udp.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ static struct sock *udp_get_idx(struct seq_file *seq, loff_t pos)
15501550
}
15511551

15521552
static void *udp_seq_start(struct seq_file *seq, loff_t *pos)
1553+
__acquires(udp_hash_lock)
15531554
{
15541555
read_lock(&udp_hash_lock);
15551556
return *pos ? udp_get_idx(seq, *pos-1) : (void *)1;
@@ -1569,6 +1570,7 @@ static void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
15691570
}
15701571

15711572
static void udp_seq_stop(struct seq_file *seq, void *v)
1573+
__releases(udp_hash_lock)
15721574
{
15731575
read_unlock(&udp_hash_lock);
15741576
}

‎net/ipv6/anycast.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ static struct ifacaddr6 *ac6_get_idx(struct seq_file *seq, loff_t pos)
504504
}
505505

506506
static void *ac6_seq_start(struct seq_file *seq, loff_t *pos)
507+
__acquires(dev_base_lock)
507508
{
508509
read_lock(&dev_base_lock);
509510
return ac6_get_idx(seq, *pos);
@@ -518,6 +519,7 @@ static void *ac6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
518519
}
519520

520521
static void ac6_seq_stop(struct seq_file *seq, void *v)
522+
__releases(dev_base_lock)
521523
{
522524
struct ac6_iter_state *state = ac6_seq_private(seq);
523525
if (likely(state->idev != NULL)) {

‎net/ipv6/ip6_flowlabel.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ static struct ip6_flowlabel *ip6fl_get_idx(struct seq_file *seq, loff_t pos)
629629
}
630630

631631
static void *ip6fl_seq_start(struct seq_file *seq, loff_t *pos)
632+
__acquires(ip6_fl_lock)
632633
{
633634
read_lock_bh(&ip6_fl_lock);
634635
return *pos ? ip6fl_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
@@ -647,6 +648,7 @@ static void *ip6fl_seq_next(struct seq_file *seq, void *v, loff_t *pos)
647648
}
648649

649650
static void ip6fl_seq_stop(struct seq_file *seq, void *v)
651+
__releases(ip6_fl_lock)
650652
{
651653
read_unlock_bh(&ip6_fl_lock);
652654
}

0 commit comments

Comments
 (0)