[net-next,04/17] Allocate and free cork in inet6_sk.

Message ID 5e5dcbb87d4b57a347c5146373c75737967e4cd0.1697989543.git.ozlinuxc@gmail.com
State New
Headers
Series Change cork to a pointer in sockets |

Commit Message

Oliver Crumrine Oct. 22, 2023, 4:20 p.m. UTC
  Allocate both the inet6_cork and inet_cork_full here, and free the
inet6_cork. (The inet_cork_full is freed in inet_release called at
the last line of inet6_release)

Signed-off-by: Oliver Crumrine <ozlinuxc@gmail.com>
---
 net/ipv6/af_inet6.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 368824fe9719..33e92826361f 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -221,6 +221,7 @@  static int inet6_create(struct net *net, struct socket *sock, int protocol,
 	np->mc_all	= 1;
 	np->pmtudisc	= IPV6_PMTUDISC_WANT;
 	np->repflow	= net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ESTABLISHED;
+	np->cork	= kzalloc(sizeof(struct inet6_cork), GFP_KERNEL);
 	sk->sk_ipv6only	= net->ipv6.sysctl.bindv6only;
 	sk->sk_txrehash = READ_ONCE(net->core.sysctl_txrehash);
 
@@ -234,6 +235,7 @@  static int inet6_create(struct net *net, struct socket *sock, int protocol,
 	inet->mc_index	= 0;
 	RCU_INIT_POINTER(inet->mc_list, NULL);
 	inet->rcv_tos	= 0;
+	inet->cork = kzalloc(sizeof(struct inet_cork_full), GFP_KERNEL);
 
 	if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
 		inet->pmtudisc = IP_PMTUDISC_DONT;
@@ -481,6 +483,9 @@  int inet6_release(struct socket *sock)
 	/* Free ac lists */
 	ipv6_sock_ac_close(sk);
 
+	/* Free cork */
+	kfree(inet6_sk(sk)->cork);
+
 	return inet_release(sock);
 }
 EXPORT_SYMBOL(inet6_release);