diff mbox series

[net-next,v1] virtio/vsock: check transport before skb allocation

Message ID 08d61bef-0c11-c7f9-9266-cb2109070314@sberdevices.ru (mailing list archive)
State Accepted
Commit 4d1f51551777b4a8e6f5503f4d64625586de2c6d
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1] virtio/vsock: check transport before skb allocation | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch warning CHECK: From:/Signed-off-by: email comments mismatch: 'From: Arseniy Krasnov <avkrasnov@sberdevices.ru>' != 'Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Arseniy Krasnov March 20, 2023, 5:43 p.m. UTC
Pointer to transport could be checked before allocation of skbuff, thus
there is no need to free skbuff when this pointer is NULL.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
---
 net/vmw_vsock/virtio_transport_common.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Pavan Chebbi March 21, 2023, 4:46 a.m. UTC | #1
On Mon, Mar 20, 2023 at 11:25 PM Arseniy Krasnov
<avkrasnov@sberdevices.ru> wrote:
>
> Pointer to transport could be checked before allocation of skbuff, thus
> there is no need to free skbuff when this pointer is NULL.
>
> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
> Reviewed-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
> ---

Looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>

>  net/vmw_vsock/virtio_transport_common.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index cda587196475..607149259e8b 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -867,6 +867,9 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
>         if (le16_to_cpu(hdr->op) == VIRTIO_VSOCK_OP_RST)
>                 return 0;
>
> +       if (!t)
> +               return -ENOTCONN;
> +
>         reply = virtio_transport_alloc_skb(&info, 0,
>                                            le64_to_cpu(hdr->dst_cid),
>                                            le32_to_cpu(hdr->dst_port),
> @@ -875,11 +878,6 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
>         if (!reply)
>                 return -ENOMEM;
>
> -       if (!t) {
> -               kfree_skb(reply);
> -               return -ENOTCONN;
> -       }
> -
>         return t->send_pkt(reply);
>  }
>
> --
> 2.25.1
patchwork-bot+netdevbpf@kernel.org March 22, 2023, 10:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 20 Mar 2023 20:43:29 +0300 you wrote:
> Pointer to transport could be checked before allocation of skbuff, thus
> there is no need to free skbuff when this pointer is NULL.
> 
> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
> Reviewed-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v1] virtio/vsock: check transport before skb allocation
    https://git.kernel.org/netdev/net-next/c/4d1f51551777

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index cda587196475..607149259e8b 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -867,6 +867,9 @@  static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
 	if (le16_to_cpu(hdr->op) == VIRTIO_VSOCK_OP_RST)
 		return 0;
 
+	if (!t)
+		return -ENOTCONN;
+
 	reply = virtio_transport_alloc_skb(&info, 0,
 					   le64_to_cpu(hdr->dst_cid),
 					   le32_to_cpu(hdr->dst_port),
@@ -875,11 +878,6 @@  static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
 	if (!reply)
 		return -ENOMEM;
 
-	if (!t) {
-		kfree_skb(reply);
-		return -ENOTCONN;
-	}
-
 	return t->send_pkt(reply);
 }