Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Acked-by: H.K. Jerry Chu <hkchu@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
        return foc->len != -1;
 }
 
+extern void tcp_sock_destruct(struct sock *sk);
+
 static inline int fastopen_init_queue(struct sock *sk, int backlog)
 {
        struct request_sock_queue *queue =
                    sk->sk_allocation);
                if (queue->fastopenq == NULL)
                        return -ENOMEM;
+
+               sk->sk_destruct = tcp_sock_destruct;
                spin_lock_init(&queue->fastopenq->lock);
        }
        queue->fastopenq->max_qlen = backlog;
 
                pr_err("Attempt to release alive inet socket %p\n", sk);
                return;
        }
-       if (sk->sk_protocol == IPPROTO_TCP)
-               kfree(inet_csk(sk)->icsk_accept_queue.fastopenq);
 
        WARN_ON(atomic_read(&sk->sk_rmem_alloc));
        WARN_ON(atomic_read(&sk->sk_wmem_alloc));
 
 }
 EXPORT_SYMBOL(tcp_disconnect);
 
+void tcp_sock_destruct(struct sock *sk)
+{
+       inet_sock_destruct(sk);
+
+       kfree(inet_csk(sk)->icsk_accept_queue.fastopenq);
+}
+
 static inline bool tcp_can_repair_sock(const struct sock *sk)
 {
        return capable(CAP_NET_ADMIN) &&