diff options
author | Jeremy Kerr <jk@codeconstruct.com.au> | 2023-01-26 09:45:51 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-28 11:26:09 +0300 |
commit | 60bd1d9008a50cc78c4033a16a6f5d78210d481c (patch) | |
tree | 288300a5ff8f036e7c06077f5aab42087fb86c3b /net | |
parent | 422ae7d9c7221e8d4c8526d0f54106307d69d2dc (diff) | |
download | linux-60bd1d9008a50cc78c4033a16a6f5d78210d481c.tar.xz |
net: mctp: purge receive queues on sk destruction
We may have pending skbs in the receive queue when the sk is being
destroyed; add a destructor to purge the queue.
MCTP doesn't use the error queue, so only the receive_queue is purged.
Fixes: 833ef3b91de6 ("mctp: Populate socket implementation")
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://lore.kernel.org/r/20230126064551.464468-1-jk@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/mctp/af_mctp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c index 45bbe3e54cc2..3150f3f0c872 100644 --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -587,6 +587,11 @@ static void mctp_sk_unhash(struct sock *sk) del_timer_sync(&msk->key_expiry); } +static void mctp_sk_destruct(struct sock *sk) +{ + skb_queue_purge(&sk->sk_receive_queue); +} + static struct proto mctp_proto = { .name = "MCTP", .owner = THIS_MODULE, @@ -623,6 +628,7 @@ static int mctp_pf_create(struct net *net, struct socket *sock, return -ENOMEM; sock_init_data(sock, sk); + sk->sk_destruct = mctp_sk_destruct; rc = 0; if (sk->sk_prot->init) |