Commit d2c3a4ba authored by Xin Long's avatar Xin Long Committed by David S. Miller

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: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 885b8b4d
...@@ -759,7 +759,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, ...@@ -759,7 +759,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
err = dst_cache_init(&ub->rcast.dst_cache, GFP_ATOMIC); err = dst_cache_init(&ub->rcast.dst_cache, GFP_ATOMIC);
if (err) if (err)
goto err; goto free;
/** /**
* The bcast media address port is used for all peers and the ip * 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,13 +771,14 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
else else
err = tipc_udp_rcast_add(b, &remote); err = tipc_udp_rcast_add(b, &remote);
if (err) if (err)
goto err; goto free;
return 0; return 0;
err:
free:
dst_cache_destroy(&ub->rcast.dst_cache); dst_cache_destroy(&ub->rcast.dst_cache);
if (ub->ubsock) udp_tunnel_sock_release(ub->ubsock);
udp_tunnel_sock_release(ub->ubsock); err:
kfree(ub); kfree(ub);
return err; return err;
} }
...@@ -795,8 +796,7 @@ static void cleanup_bearer(struct work_struct *work) ...@@ -795,8 +796,7 @@ static void cleanup_bearer(struct work_struct *work)
} }
dst_cache_destroy(&ub->rcast.dst_cache); dst_cache_destroy(&ub->rcast.dst_cache);
if (ub->ubsock) udp_tunnel_sock_release(ub->ubsock);
udp_tunnel_sock_release(ub->ubsock);
synchronize_net(); synchronize_net();
kfree(ub); kfree(ub);
} }
...@@ -811,8 +811,7 @@ static void tipc_udp_disable(struct tipc_bearer *b) ...@@ -811,8 +811,7 @@ static void tipc_udp_disable(struct tipc_bearer *b)
pr_err("UDP bearer instance not found\n"); pr_err("UDP bearer instance not found\n");
return; return;
} }
if (ub->ubsock) sock_set_flag(ub->ubsock->sk, SOCK_DEAD);
sock_set_flag(ub->ubsock->sk, SOCK_DEAD);
RCU_INIT_POINTER(ub->bearer, NULL); RCU_INIT_POINTER(ub->bearer, NULL);
/* sock_release need to be done outside of rtnl lock */ /* sock_release need to be done outside of rtnl lock */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment