Staging: batman-adv: Track references of batman_if in set_primary_if
authorSven Eckelmann <sven.eckelmann@gmx.de>
Sat, 18 Sep 2010 19:01:21 +0000 (21:01 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Sep 2010 23:29:50 +0000 (16:29 -0700)
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 <sven.eckelmann@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/batman-adv/hard-interface.c

index eef5631..a9d6f1d 100644 (file)
@@ -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;