All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCH next] batman-adv: avoid potential race condition when adding a new neighbour
Date: Mon, 27 Jan 2014 09:22:35 +0100	[thread overview]
Message-ID: <52E6174B.1070101@meshcoding.com> (raw)
In-Reply-To: <5373996.23YD93TvXH@diderot>

[-- Attachment #1: Type: text/plain, Size: 1663 bytes --]

On 27/01/14 09:10, Marek Lindner wrote:
> On Friday 24 January 2014 09:58:03 Antonio Quartulli wrote:
>> @@ -281,14 +281,23 @@ batadv_iv_ogm_neigh_new(struct batadv_hard_iface
>> *hard_iface, neigh_node->orig_node = orig_neigh;
>>  	neigh_node->if_incoming = hard_iface;
>>
>> -	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
>> -		   "Creating new neighbor %pM for orig_node %pM on interface %s\n",
>> -		   neigh_addr, orig_node->orig, hard_iface->net_dev->name);
>> -
>>  	spin_lock_bh(&orig_node->neigh_list_lock);
>> -	hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
>> +	tmp_neigh_node = batadv_neigh_node_get(orig_node, hard_iface,
>> +					       neigh_addr);
>> +	if (!tmp_neigh_node) {
>> +		hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
>> +	} else {
>> +		kfree(neigh_node);
>> +		neigh_node = tmp_neigh_node;
>> +	}
> 
> What about hard_iface->refcount ?

True.
hard_iface must be released if we found an already existent neighbour.
I'll put a batadv_hardif_free_ref(hard_iface); right after the
kfree(neigh_node);.

> 
> 
>>  /**
>> + * batadv_neigh_node_get - retrieve a neighbour from the list
>> + * @orig_node: originator which the neighbour belongs to
>> + * @hard_iface: the interface where this neighbour is connected to
>> + * @addr: the address of the neighbour
>> + *
>> + * Looks for and possibly return a neighbour belonging to this originator
>> list + * which is connected through the provided hard interface.
> 
> 'Looks and return' does not work. Either 'look and return' or 'looks and 
> returns'.

Yap, thanks!


I'll send v2 soon!

-- 
Antonio Quartulli


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

      reply	other threads:[~2014-01-27  8:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24  8:58 [B.A.T.M.A.N.] [PATCH next] batman-adv: avoid potential race condition when adding a new neighbour Antonio Quartulli
2014-01-27  8:10 ` Marek Lindner
2014-01-27  8:22   ` Antonio Quartulli [this message]

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=52E6174B.1070101@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.