netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] neigh: fix a possible leak issue of neigh entry
@ 2015-05-13  5:43 Ying Xue
  2015-05-13  6:20 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Ying Xue @ 2015-05-13  5:43 UTC (permalink / raw)
  To: netdev; +Cc: davem

Once modifying a pending timer of a neighbour, it's insufficient to
post a warning message. Instead we should not take the neighbour's
reference count at the same time, otherwise, it causes an issue that
the neighbour cannot be freed forever.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
---
 net/core/neighbour.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 3de6542..5595db3 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -164,10 +164,11 @@ static int neigh_forced_gc(struct neigh_table *tbl)
 
 static void neigh_add_timer(struct neighbour *n, unsigned long when)
 {
-	neigh_hold(n);
-	if (unlikely(mod_timer(&n->timer, when))) {
-		printk("NEIGH: BUG, double timer add, state is %x\n",
-		       n->nud_state);
+	if (likely(!mod_timer(&n->timer, when))) {
+		neigh_hold(n);
+	} else {
+		pr_warn("NEIGH: BUG, double timer add, state is %x\n",
+			n->nud_state);
 		dump_stack();
 	}
 }
-- 
1.7.9.5

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

end of thread, other threads:[~2015-05-13 13:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-13  5:43 [PATCH net-next] neigh: fix a possible leak issue of neigh entry Ying Xue
2015-05-13  6:20 ` Eric Dumazet
2015-05-13  7:25   ` Ying Xue
2015-05-13 10:32     ` Ying Xue
2015-05-13 13:07       ` Eric Dumazet

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).