netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [IPV4] ROUTE: Avoid sparse warnings
@ 2008-01-07 11:01 Eric Dumazet
  2008-01-07 12:11 ` Herbert Xu
  2008-01-08  6:54 ` David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Eric Dumazet @ 2008-01-07 11:01 UTC (permalink / raw)
  To: David Miller; +Cc: netdev@vger.kernel.org

  CHECK   net/ipv4/route.c
net/ipv4/route.c:298:2: warning: context imbalance in 'rt_cache_get_first' - wrong count at exit
net/ipv4/route.c:307:3: warning: context imbalance in 'rt_cache_get_next' - unexpected unlock
net/ipv4/route.c:346:3: warning: context imbalance in 'rt_cache_seq_stop' - unexpected unlock

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 10915bb..fec0571 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -289,11 +289,11 @@ static struct rtable *rt_cache_get_first(struct seq_file *seq)
 	struct rt_cache_iter_state *st = seq->private;
 
 	for (st->bucket = rt_hash_mask; st->bucket >= 0; --st->bucket) {
-		rcu_read_lock_bh();
 		r = rt_hash_table[st->bucket].chain;
 		if (r)
 			break;
 		rcu_read_unlock_bh();
+		rcu_read_lock_bh();
 	}
 	return r;
 }
@@ -305,9 +305,9 @@ static struct rtable *rt_cache_get_next(struct seq_file *seq, struct rtable *r)
 	r = r->u.dst.rt_next;
 	while (!r) {
 		rcu_read_unlock_bh();
+		rcu_read_lock_bh();
 		if (--st->bucket < 0)
 			break;
-		rcu_read_lock_bh();
 		r = rt_hash_table[st->bucket].chain;
 	}
 	return r;
@@ -324,7 +324,9 @@ static struct rtable *rt_cache_get_idx(struct seq_file *seq, loff_t pos)
 }
 
 static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
+	__acquires(RCU_BH)
 {
+	rcu_read_lock_bh();
 	return *pos ? rt_cache_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
 
@@ -341,9 +343,9 @@ static void *rt_cache_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 }
 
 static void rt_cache_seq_stop(struct seq_file *seq, void *v)
+	__releases(RCU_BH)
 {
-	if (v && v != SEQ_START_TOKEN)
-		rcu_read_unlock_bh();
+	rcu_read_unlock_bh();
 }
 
 static int rt_cache_seq_show(struct seq_file *seq, void *v)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-01-08 12:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-07 11:01 [IPV4] ROUTE: Avoid sparse warnings Eric Dumazet
2008-01-07 12:11 ` Herbert Xu
2008-01-07 13:56   ` Eric Dumazet
2008-01-07 20:38     ` Herbert Xu
2008-01-07 20:46       ` Eric Dumazet
2008-01-07 20:48         ` Herbert Xu
2008-01-08  6:54 ` David Miller
2008-01-08  7:53   ` Eric Dumazet
2008-01-08  9:34     ` David Miller
2008-01-08 12:59     ` Jarek Poplawski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).