diff mbox series

[net] net: mctp: purge receive queues on sk destruction

Message ID 20230126064551.464468-1-jk@codeconstruct.com.au (mailing list archive)
State Accepted
Commit 60bd1d9008a50cc78c4033a16a6f5d78210d481c
Delegated to: Netdev Maintainers
Headers show
Series [net] net: mctp: purge receive queues on sk destruction | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jeremy Kerr Jan. 26, 2023, 6:45 a.m. UTC
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>
---
 net/mctp/af_mctp.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Pavan Chebbi Jan. 26, 2023, 9:26 a.m. UTC | #1
On Thu, Jan 26, 2023 at 12:16 PM Jeremy Kerr <jk@codeconstruct.com.au> wrote:
>
> 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>
> ---
>  net/mctp/af_mctp.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> 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)
> --
> 2.35.1
>
Looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
patchwork-bot+netdevbpf@kernel.org Jan. 28, 2023, 8:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 Jan 2023 14:45:51 +0800 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net] net: mctp: purge receive queues on sk destruction
    https://git.kernel.org/netdev/net/c/60bd1d9008a5

You are awesome, thank you!
diff mbox series

Patch

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)