diff options
author | Eric Dumazet <edumazet@google.com> | 2019-04-23 12:24:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-24 14:46:54 -0400 |
commit | 4109a2c3b91e5f38e401fc4ea56848e65e429785 (patch) | |
tree | 5926a946b170e83fa231881157cfa66d6d6f8723 /net/tipc | |
parent | a65120bae4b7425a39c5783aa3d4fc29677eef0e (diff) |
tipc: tipc_udp_recv() cleanup vs rcu verbs
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>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/udp_media.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 6f166fbbfff1..7413cbc9b638 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c | |||
@@ -354,10 +354,9 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb) | |||
354 | skb_pull(skb, sizeof(struct udphdr)); | 354 | skb_pull(skb, sizeof(struct udphdr)); |
355 | hdr = buf_msg(skb); | 355 | hdr = buf_msg(skb); |
356 | 356 | ||
357 | rcu_read_lock(); | 357 | b = rcu_dereference(ub->bearer); |
358 | b = rcu_dereference_rtnl(ub->bearer); | ||
359 | if (!b) | 358 | if (!b) |
360 | goto rcu_out; | 359 | goto out; |
361 | 360 | ||
362 | if (b && test_bit(0, &b->up)) { | 361 | if (b && test_bit(0, &b->up)) { |
363 | tipc_rcv(sock_net(sk), skb, b); | 362 | tipc_rcv(sock_net(sk), skb, b); |
@@ -368,11 +367,9 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb) | |||
368 | if (unlikely(msg_user(hdr) == LINK_CONFIG)) { | 367 | if (unlikely(msg_user(hdr) == LINK_CONFIG)) { |
369 | err = tipc_udp_rcast_disc(b, skb); | 368 | err = tipc_udp_rcast_disc(b, skb); |
370 | if (err) | 369 | if (err) |
371 | goto rcu_out; | 370 | goto out; |
372 | } | 371 | } |
373 | 372 | ||
374 | rcu_out: | ||
375 | rcu_read_unlock(); | ||
376 | out: | 373 | out: |
377 | kfree_skb(skb); | 374 | kfree_skb(skb); |
378 | return 0; | 375 | return 0; |