Skip to content

Commit

Permalink
net: Remove spinlock from get_net_ns_by_id()
Browse files Browse the repository at this point in the history
idr_find() is safe under rcu_read_lock() and
maybe_get_net() guarantees that net is alive.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kirill Tkhai authored and David S. Miller committed Jan 17, 2018
1 parent 0c06bea commit 4215727
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,9 @@ struct net *get_net_ns_by_id(struct net *net, int id)
return NULL;

rcu_read_lock();
spin_lock_bh(&net->nsid_lock);
peer = idr_find(&net->netns_ids, id);
if (peer)
peer = maybe_get_net(peer);
spin_unlock_bh(&net->nsid_lock);
rcu_read_unlock();

return peer;
Expand Down

0 comments on commit 4215727

Please sign in to comment.