Skip to content

Commit

Permalink
tipc: tipc_udp_recv() cleanup vs rcu verbs
Browse files Browse the repository at this point in the history
First thing tipc_udp_recv() does is to use rcu_dereference_sk_user_data(),
and this is really hinting we already own rcu_read_lock() from the caller
(UDP stack).

No need to add another rcu_read_lock()/rcu_read_unlock() pair.

Also use rcu_dereference() instead of rcu_dereference_rtnl()
in the data path.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jon Maloy <jon.maloy@ericsson.com>
Cc: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Apr 24, 2019
1 parent a65120b commit 4109a2c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions net/tipc/udp_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,9 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
skb_pull(skb, sizeof(struct udphdr));
hdr = buf_msg(skb);

rcu_read_lock();
b = rcu_dereference_rtnl(ub->bearer);
b = rcu_dereference(ub->bearer);
if (!b)
goto rcu_out;
goto out;

if (b && test_bit(0, &b->up)) {
tipc_rcv(sock_net(sk), skb, b);
Expand All @@ -368,11 +367,9 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
if (unlikely(msg_user(hdr) == LINK_CONFIG)) {
err = tipc_udp_rcast_disc(b, skb);
if (err)
goto rcu_out;
goto out;
}

rcu_out:
rcu_read_unlock();
out:
kfree_skb(skb);
return 0;
Expand Down

0 comments on commit 4109a2c

Please sign in to comment.