Skip to content

Commit

Permalink
mptcp: defer freeing of cached ext until last moment
Browse files Browse the repository at this point in the history
access to msk->cached_ext is only legal if the msk is locked or all
concurrent accesses are impossible.

Furthermore, once we start to tear down, we must make sure nothing else
can step in and allocate a new cached ext.

So place this code in the destroy callback where it belongs.

Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Florian Westphal authored and davem330 committed Jan 29, 2020
1 parent 44efc78 commit c9fd9c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ static void __mptcp_close(struct sock *sk, long timeout)
__mptcp_close_ssk(sk, ssk, subflow, timeout);
}

if (msk->cached_ext)
__skb_ext_put(msk->cached_ext);
release_sock(sk);
sk_common_release(sk);
}
Expand Down Expand Up @@ -776,6 +774,10 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,

static void mptcp_destroy(struct sock *sk)
{
struct mptcp_sock *msk = mptcp_sk(sk);

if (msk->cached_ext)
__skb_ext_put(msk->cached_ext);
}

static int mptcp_setsockopt(struct sock *sk, int level, int optname,
Expand Down

0 comments on commit c9fd9c5

Please sign in to comment.