From patchwork Wed May 13 05:43:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying Xue X-Patchwork-Id: 471682 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3C011140D1A for ; Wed, 13 May 2015 15:43:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751892AbbEMFnj (ORCPT ); Wed, 13 May 2015 01:43:39 -0400 Received: from mail.windriver.com ([147.11.1.11]:32859 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639AbbEMFni (ORCPT ); Wed, 13 May 2015 01:43:38 -0400 Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail.windriver.com (8.14.9/8.14.9) with ESMTP id t4D5habN024603 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 12 May 2015 22:43:37 -0700 (PDT) Received: from ying.corp.ad.wrs.com (128.224.163.180) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.224.2; Tue, 12 May 2015 22:43:36 -0700 From: Ying Xue To: CC: Subject: [PATCH net-next] neigh: fix a possible leak issue of neigh entry Date: Wed, 13 May 2015 13:43:34 +0800 Message-ID: <1431495814-22759-1-git-send-email-ying.xue@windriver.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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(); } }