[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <39ff1697-a110-ac0e-5fca-26ac559b5291@cogentembedded.com>
Date: Tue, 23 Aug 2016 16:20:00 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Simon Wunderlich <sw@...onwunderlich.de>, davem@...emloft.net
Cc: netdev@...r.kernel.org, b.a.t.m.a.n@...ts.open-mesh.org,
Sven Eckelmann <sven@...fation.org>,
Marek Lindner <mareklindner@...mailbox.ch>
Subject: Re: [PATCH 14/20] batman-adv: Place kref_get for softif_vlan near use
Hello.
On 8/22/2016 4:56 PM, Simon Wunderlich wrote:
> From: Sven Eckelmann <sven@...fation.org>
>
> It is hard to understand why the refcnt is increased when it isn't done
> near the actual place the new reference is used. So using kref_get right
> before the place which requires the reference and in the same function
> helps to avoid accidental problems caused by incorrect reference counting.
I don't think your boilerplate log works for this patch where you are
*adding* the ref-counting.
> Signed-off-by: Sven Eckelmann <sven@...fation.org>
> Signed-off-by: Marek Lindner <mareklindner@...mailbox.ch>
> Signed-off-by: Simon Wunderlich <sw@...onwunderlich.de>
> ---
> net/batman-adv/soft-interface.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
> index e508bf5..49e16b6 100644
> --- a/net/batman-adv/soft-interface.c
> +++ b/net/batman-adv/soft-interface.c
> @@ -594,6 +594,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
> }
>
> spin_lock_bh(&bat_priv->softif_vlan_list_lock);
> + kref_get(&vlan->refcount);
> hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list);
> spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
>
> @@ -604,6 +605,9 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
> bat_priv->soft_iface->dev_addr, vid,
> BATADV_NULL_IFINDEX, BATADV_NO_MARK);
>
> + /* don't return reference to new softif_vlan */
> + batadv_softif_vlan_put(vlan);
> +
> return 0;
> }
>
MBR, Sergei
Powered by blists - more mailing lists