From patchwork Thu May 5 12:15:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 975 Return-Path: Received: from nm10-vm0.bullet.mail.ukl.yahoo.com (nm10-vm0.bullet.mail.ukl.yahoo.com [217.146.183.242]) by open-mesh.org (Postfix) with SMTP id DBF6B1541D4 for ; Thu, 5 May 2011 14:16:41 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.181] by nm10.bullet.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:16:40 -0000 Received: from [77.238.184.63] by tm12.bullet.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:16:40 -0000 Received: from [127.0.0.1] by smtp132.mail.ukl.yahoo.com with NNFMP; 05 May 2011 12:16:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1304597800; bh=72Os/2GdtNvA/x/zpuKHq3JAbcqdxhS5iLkyHw6QatA=; 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; b=AuUCiHv5/mPAoY0xW9VvVI739WG0PiKer1LV0hX2R9sN526eoUONo6jrWUOg1ZD6UhUSXGce5uH1NSeidSqleWeWdiJP3/HwNvVR84323n+f5b6zTz9paPlAWYoKRMiPkNZhqCrvZb520YNmhUjGFbrOrXWU3ASAuStwdXURaC4= X-Yahoo-Newman-Id: 725546.43730.bm@smtp132.mail.ukl.yahoo.com Received: from localhost (lindner_marek@90.35.35.27 with plain) by smtp132.mail.ukl.yahoo.com with SMTP; 05 May 2011 12:16:40 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: DaBYtsQVM1lzhQ3uz0_LiVHl7NNzizkQdgIrr_O.UC811Se 3Gc07PqvpzaA3wBeeD9e.JUEa95O9aZRS3JkIqezqRv6KCn2aT3yuDy0MyAe e_.WUvsvTL4Tt.koIFDX.lZzcDmk1G2g4iLn6lgCajgm9AeAJPSiUmK4FVgk 6Ogj4IZfEc8UIZUYHbtM8pOQCQDCUyWPvnawYjKxGH5EHSJtW2j6PBQvMU8N YvfNv6.KSCgL0Ykz4YOLksoEhof0lTk2x_AsSPCmRmN7Ikt7.wIKaIZcFblH cy77S17Pk4d55ketNs_NO7iLaeekvUe4svx0h5p_VWswrletWdlEgbUdItpf fcDreDA-- 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:15:57 +0200 Message-Id: <1304597757-17035-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Fix rcu_lock 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:16:42 -0000 Signed-off-by: Marek Lindner --- 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)