From patchwork Thu May 5 12:19:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 959 Return-Path: Received: from nm12.bullet.mail.ukl.yahoo.com (nm12.bullet.mail.ukl.yahoo.com [217.146.183.186]) by open-mesh.org (Postfix) with SMTP id EC6761541D4 for ; Thu, 5 May 2011 14:19:51 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.208] by nm12.bullet.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:19:51 -0000 Received: from [77.238.184.61] by tm1.bullet.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:19:51 -0000 Received: from [127.0.0.1] by smtp130.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:19:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1304597991; bh=4QpLprmKqMFbiojVqN3iXeAR9yQxepTn/mw4iaOjv3o=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=aJK6STMH9imMVlchH6JGWPF6qBNQqyr2Rh5ab8XsLiZgu4Q0lTzQ6o6z0yOcuSbMu3/fBXNlkB0/ukzS/z/5Ifnk3lS/fetHmc2UUorSnXHdiCpi2zOQRk+Kt1jRbf/c6Usb7+MH0MIzk6pfxu1/zgozfxrBmYhH6EMmtjMOEsk= X-Yahoo-Newman-Id: 460067.77941.bm@smtp130.mail.ukl.yahoo.com Received: from localhost (lindner_marek@90.35.35.27 with plain) by smtp130.mail.ukl.yahoo.com with SMTP; 05 May 2011 12:19:51 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: zGeMCogVM1nJx8jYGKjbdf6DRC3CWzOPesxlbXNZL8_hX97 QHt4gMeA9CRJQ0Mj0B8fzCia3zncV2z5kFMGWi1zfyg3MxulUneG8QYA9Z2_ Ul9yflA7k6Ir5JwC3Sx06VQZ7MNm7UKUEVofuuTGB5Xf_z6zs40g2HTC4efc lkp4n_uWzGeZgoUzBgv323nmRqr6OVrGFcGqugnSVRq29vgmlx3_FPtZbACH PyXBg_4u7P_TE70UjWT_HSwuEgaS95XbzL49VCiw2I4PzDKcj4rDlIZIdzm. JfIzFBcxyKRGD9k7MHtgcRvqL1IdOXAHpLBV9jmHtFw2AOnB6ujbTNg-- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 5 May 2011 14:19:09 +0200 Message-Id: <1304597949-17173-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1304597757-17035-1-git-send-email-lindner_marek@yahoo.de> References: <1304597757-17035-1-git-send-email-lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCHv2] batman-adv: Fix refcount imbalance in find_router X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2011 12:19:52 -0000 Signed-off-by: Marek Lindner Acked-by: Sven Eckelmann --- Fixed wrong subject. routing.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/routing.c b/routing.c index 49f5715..d8cde2b 100644 --- a/routing.c +++ b/routing.c @@ -1213,7 +1213,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, router = orig_node_get_router(orig_node); if (!router) - return NULL; + goto err; /* without bonding, the first node should * always choose the default router. */ @@ -1222,10 +1222,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, rcu_read_lock(); /* select default router to output */ router_orig = router->orig_node; - if (!router_orig) { - rcu_read_unlock(); - return NULL; - } + if (!router_orig) + goto err_unlock; if ((!recv_if) && (!bonding_enabled)) goto return_router; @@ -1268,6 +1266,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, return_router: rcu_read_unlock(); return router; +err_unlock: + rcu_read_unlock(); +err: + if (router) + neigh_node_free_ref(router); + return NULL; } static int check_unicast_packet(struct sk_buff *skb, int hdr_size)