diff options
author | Xin Long <lucien.xin@gmail.com> | 2019-07-01 12:57:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-07-02 18:13:15 -0400 |
commit | d2c3a4ba25fbfb6b2c7b5fe423be1b287954cd4c (patch) | |
tree | ac0f64e05fe8bdfecc390752134edb389b5f0fbc /net/tipc | |
parent | 885b8b4dbba5ca6114db0fcd0737fe2512650745 (diff) |
tipc: remove ub->ubsock checks
Both tipc_udp_enable and tipc_udp_disable are called under rtnl_lock,
ub->ubsock could never be NULL in tipc_udp_disable and cleanup_bearer,
so remove the check.
Also remove the one in tipc_udp_enable by adding "free" label.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/udp_media.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index b8962df07d36..c0f694ae57ab 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c | |||
@@ -759,7 +759,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, | |||
759 | 759 | ||
760 | err = dst_cache_init(&ub->rcast.dst_cache, GFP_ATOMIC); | 760 | err = dst_cache_init(&ub->rcast.dst_cache, GFP_ATOMIC); |
761 | if (err) | 761 | if (err) |
762 | goto err; | 762 | goto free; |
763 | 763 | ||
764 | /** | 764 | /** |
765 | * The bcast media address port is used for all peers and the ip | 765 | * The bcast media address port is used for all peers and the ip |
@@ -771,13 +771,14 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, | |||
771 | else | 771 | else |
772 | err = tipc_udp_rcast_add(b, &remote); | 772 | err = tipc_udp_rcast_add(b, &remote); |
773 | if (err) | 773 | if (err) |
774 | goto err; | 774 | goto free; |
775 | 775 | ||
776 | return 0; | 776 | return 0; |
777 | err: | 777 | |
778 | free: | ||
778 | dst_cache_destroy(&ub->rcast.dst_cache); | 779 | dst_cache_destroy(&ub->rcast.dst_cache); |
779 | if (ub->ubsock) | 780 | udp_tunnel_sock_release(ub->ubsock); |
780 | udp_tunnel_sock_release(ub->ubsock); | 781 | err: |
781 | kfree(ub); | 782 | kfree(ub); |
782 | return err; | 783 | return err; |
783 | } | 784 | } |
@@ -795,8 +796,7 @@ static void cleanup_bearer(struct work_struct *work) | |||
795 | } | 796 | } |
796 | 797 | ||
797 | dst_cache_destroy(&ub->rcast.dst_cache); | 798 | dst_cache_destroy(&ub->rcast.dst_cache); |
798 | if (ub->ubsock) | 799 | udp_tunnel_sock_release(ub->ubsock); |
799 | udp_tunnel_sock_release(ub->ubsock); | ||
800 | synchronize_net(); | 800 | synchronize_net(); |
801 | kfree(ub); | 801 | kfree(ub); |
802 | } | 802 | } |
@@ -811,8 +811,7 @@ static void tipc_udp_disable(struct tipc_bearer *b) | |||
811 | pr_err("UDP bearer instance not found\n"); | 811 | pr_err("UDP bearer instance not found\n"); |
812 | return; | 812 | return; |
813 | } | 813 | } |
814 | if (ub->ubsock) | 814 | sock_set_flag(ub->ubsock->sk, SOCK_DEAD); |
815 | sock_set_flag(ub->ubsock->sk, SOCK_DEAD); | ||
816 | RCU_INIT_POINTER(ub->bearer, NULL); | 815 | RCU_INIT_POINTER(ub->bearer, NULL); |
817 | 816 | ||
818 | /* sock_release need to be done outside of rtnl lock */ | 817 | /* sock_release need to be done outside of rtnl lock */ |