b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <mareklindner@neomailbox.ch>
Subject: [B.A.T.M.A.N.] [PATCH 01/20] batman-adv: Place kref_get for orig_node_vlan near use
Date: Mon, 22 Aug 2016 15:56:01 +0200	[thread overview]
Message-ID: <20160822135620.15337-2-sw@simonwunderlich.de> (raw)
In-Reply-To: <20160822135620.15337-1-sw@simonwunderlich.de>

From: Sven Eckelmann <sven@narfation.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.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/originator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 95c8555..5108af1 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -133,9 +133,9 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
 		goto out;
 
 	kref_init(&vlan->refcount);
-	kref_get(&vlan->refcount);
 	vlan->vid = vid;
 
+	kref_get(&vlan->refcount);
 	hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list);
 
 out:
-- 
2.9.3


  reply	other threads:[~2016-08-22 13:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 13:56 [B.A.T.M.A.N.] [PATCH 00/20] pull request for net-next: batman-adv 2016-08-16* Simon Wunderlich
2016-08-22 13:56 ` Simon Wunderlich [this message]
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 02/20] batman-adv: Place kref_get for orig_ifinfo near use Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 03/20] batman-adv: Place kref_get for tt_orig_list_entry " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 04/20] batman-adv: Place kref_get for neigh_ifinfo " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 05/20] batman-adv: Place kref_get for neigh_node " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 06/20] batman-adv: Place kref_get for orig_node " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 07/20] batman-adv: Place kref_get for tt_local_entry " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 08/20] batman-adv: Place kref_get for tt_common " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 09/20] batman-adv: Place kref_get for bla_claim " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 10/20] batman-adv: Place kref_get for bla_backbone_gw " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 11/20] batman-adv: Place kref_get for dat_entry " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 12/20] batman-adv: Place kref_get for gw_node " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 13/20] batman-adv: Place kref_get for hard_iface " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 14/20] batman-adv: Place kref_get for softif_vlan " Simon Wunderlich
2016-08-23 13:20   ` Sergei Shtylyov
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 15/20] batman-adv: Place kref_get for nc_node " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 16/20] batman-adv: Place kref_get for nc_path " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 17/20] batman-adv: Place kref_get for tvlv_container " Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 18/20] batman-adv: Place kref_get for tvlv_handler " Simon Wunderlich
2016-08-23 13:36   ` Sergei Shtylyov
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 19/20] batman-adv: Keep batadv netdev when hardif disappears Simon Wunderlich
2016-08-22 13:56 ` [B.A.T.M.A.N.] [PATCH 20/20] batman-adv: Allow to disable debugfs support Simon Wunderlich
2016-08-23  3:40 ` [B.A.T.M.A.N.] [PATCH 00/20] pull request for net-next: batman-adv 2016-08-16* David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160822135620.15337-2-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).