From patchwork Sat Sep 18 19:01:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 436 Return-Path: Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.22]) by open-mesh.org (Postfix) with SMTP id 7BB0515453A for ; Sat, 18 Sep 2010 21:00:42 +0200 (CEST) Received: (qmail invoked by alias); 18 Sep 2010 19:00:41 -0000 Received: from unknown (EHLO sven-desktop.lazhur.ath.cx) [88.130.165.18] by mail.gmx.net (mp004) with SMTP; 18 Sep 2010 21:00:41 +0200 X-Authenticated: #15668376 X-Provags-ID: V01U2FsdGVkX1/s9PIwzD7syKE4drW+Q9NQC/2SOkeGH448hjR996 rNCn9vCw4mOUw8 From: Sven Eckelmann To: greg@kroah.com Date: Sat, 18 Sep 2010 21:01:21 +0200 Message-Id: <1284836482-23431-12-git-send-email-sven.eckelmann@gmx.de> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1284836482-23431-1-git-send-email-sven.eckelmann@gmx.de> References: <1284836482-23431-1-git-send-email-sven.eckelmann@gmx.de> X-Y-GMX-Trusted: 0 Cc: b.a.t.m.a.n@lists.open-mesh.org Subject: [B.A.T.M.A.N.] [PATCH 11/12] Staging: batman-adv: Track references of batman_if in set_primary_if X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 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: Sat, 18 Sep 2010 19:00:42 -0000 set_primary_if exchanges the current primary interfaces with a new one. This is a new reference and thus we have to count it and decrease the count of the old primary interface. Signed-off-by: Sven Eckelmann --- drivers/staging/batman-adv/hard-interface.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index eef5631..a9d6f1d 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -111,9 +111,17 @@ static void set_primary_if(struct bat_priv *bat_priv, { struct batman_packet *batman_packet; struct vis_packet *vis_packet; + struct batman_if *old_if; + if (batman_if) + hardif_hold(batman_if); + + old_if = bat_priv->primary_if; bat_priv->primary_if = batman_if; + if (old_if) + hardif_put(old_if); + if (!bat_priv->primary_if) return;