diff options
author | Sven Eckelmann <sven@narfation.org> | 2016-04-11 13:06:40 +0200 |
---|---|---|
committer | Antonio Quartulli <a@unstable.cc> | 2016-05-10 18:28:29 +0800 |
commit | 17a8691502c9d2d792cfea7253b17382279ffb3e (patch) | |
tree | 6b2f476a17ff8d70d72caf5f6fbedc5b4bf7406d /net/batman-adv/hard-interface.c | |
parent | c3ba37a778ecab4f8ddb117a2ceff3e13184a7db (diff) | |
download | linux-17a8691502c9d2d792cfea7253b17382279ffb3e.tar.gz linux-17a8691502c9d2d792cfea7253b17382279ffb3e.tar.xz |
batman-adv: Use kref_get for hard_iface subfunctions
The callers of the functions using batadv_hard_iface objects already make
sure that they hold a valid reference. The subfunctions don't have
to check whether the reference counter is > 0 because this was checked by
the callers.
The kref_get function instead WARNs (with debug information) when the
reference counter would still be 0. This makes a bug in batman-adv better
visible because kref_get_unless_zero would have ignored this problem.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r-- | net/batman-adv/hard-interface.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index d3d37f3f99cf..7c1d8d7ac548 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -236,8 +236,8 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv, ASSERT_RTNL(); - if (new_hard_iface && !kref_get_unless_zero(&new_hard_iface->refcount)) - new_hard_iface = NULL; + if (new_hard_iface) + kref_get(&new_hard_iface->refcount); curr_hard_iface = rcu_dereference_protected(bat_priv->primary_if, 1); rcu_assign_pointer(bat_priv->primary_if, new_hard_iface); @@ -467,8 +467,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) goto out; - if (!kref_get_unless_zero(&hard_iface->refcount)) - goto out; + kref_get(&hard_iface->refcount); soft_iface = dev_get_by_name(net, iface_name); |