@@ -256,11 +256,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk)
{
struct mptcp_rm_list list = { .nr = 0 };
struct mptcp_subflow_context *subflow;
- struct sock *sk = (struct sock *)msk;
bool has_id_0 = false;
- int err = -EINVAL;
- lock_sock(sk);
mptcp_for_each_subflow(msk, subflow) {
if (READ_ONCE(subflow->local_id) == 0) {
has_id_0 = true;
@@ -268,7 +265,7 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk)
}
}
if (!has_id_0)
- goto remove_err;
+ return -EINVAL;
list.ids[list.nr++] = 0;
@@ -276,11 +273,7 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk)
mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock);
- err = 0;
-
-remove_err:
- release_sock(sk);
- return err;
+ return 0;
}
void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,
@@ -324,13 +317,14 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
sk = (struct sock *)msk;
+ lock_sock(sk);
+
if (id_val == 0) {
err = mptcp_userspace_pm_remove_id_zero_address(msk);
+ release_sock(sk);
goto out;
}
- lock_sock(sk);
-
spin_lock_bh(&msk->pm.lock);
match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
if (!match) {