diff mbox series

[3/3] mptcp/ipv6: mptcp_v6_prot needs costom destroy.

Message ID 6e2d1e5019b5e81d0de33a91d458929600e37a8a.1574350681.git.pabeni@redhat.com
State Accepted, archived
Delegated to: Matthieu Baerts
Headers show
Series mptcp: fix for ipv6-related oops | expand

Commit Message

Paolo Abeni Nov. 21, 2019, 3:41 p.m. UTC
Otherwise we can leak memory on close, if user space
does some setsockopt before connectiong/accepting.

Note: the squash tag points to the commit currently
introducing mptcp_destroy, but we likely want to move
such function in another one - it's currently added as empty

Squash-to: "mptcp: Add key generation and token tree"
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 3ae136f9e35c..9b384da910ce 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -974,6 +974,12 @@  void mptcp_proto_init(void)
 static struct proto_ops mptcp_v6_stream_ops;
 static struct proto mptcp_v6_prot;
 
+static void mptcp_v6_destroy(struct sock *sk)
+{
+	mptcp_destroy(sk);
+	inet6_destroy_sock(sk);
+}
+
 static struct inet_protosw mptcp_v6_protosw = {
 	.type		= SOCK_STREAM,
 	.protocol	= IPPROTO_MPTCP,
@@ -989,6 +995,7 @@  int mptcp_proto_v6_init(void)
 	mptcp_v6_prot = mptcp_prot;
 	strcpy(mptcp_v6_prot.name, "MPTCPv6");
 	mptcp_v6_prot.slab = NULL;
+	mptcp_v6_prot.destroy = mptcp_v6_destroy;
 	mptcp_v6_prot.obj_size = sizeof(struct mptcp_sock) +
 				 sizeof(struct ipv6_pinfo);