Commit 60bd1d90 authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Jakub Kicinski

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: 833ef3b9 ("mctp: Populate socket implementation")
Signed-off-by: default avatarJeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://lore.kernel.org/r/20230126064551.464468-1-jk@codeconstruct.com.auSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 422ae7d9
...@@ -587,6 +587,11 @@ static void mctp_sk_unhash(struct sock *sk) ...@@ -587,6 +587,11 @@ static void mctp_sk_unhash(struct sock *sk)
del_timer_sync(&msk->key_expiry); 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 = { static struct proto mctp_proto = {
.name = "MCTP", .name = "MCTP",
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -623,6 +628,7 @@ static int mctp_pf_create(struct net *net, struct socket *sock, ...@@ -623,6 +628,7 @@ static int mctp_pf_create(struct net *net, struct socket *sock,
return -ENOMEM; return -ENOMEM;
sock_init_data(sock, sk); sock_init_data(sock, sk);
sk->sk_destruct = mctp_sk_destruct;
rc = 0; rc = 0;
if (sk->sk_prot->init) if (sk->sk_prot->init)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment