2023-03-20 17:54:25

by Arseniy Krasnov

[permalink] [raw]
Subject: [PATCH net-next v1] virtio/vsock: check transport before skb allocation

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 <[email protected]>
Reviewed-by: Bobby Eshleman <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
---
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


2023-03-21 04:46:40

by Pavan Chebbi

[permalink] [raw]
Subject: Re: [PATCH net-next v1] virtio/vsock: check transport before skb allocation

On Mon, Mar 20, 2023 at 11:25 PM Arseniy Krasnov
<[email protected]> 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 <[email protected]>
> Reviewed-by: Bobby Eshleman <[email protected]>
> Reviewed-by: Stefano Garzarella <[email protected]>
> ---

Looks good to me.
Reviewed-by: Pavan Chebbi <[email protected]>

> 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


Attachments:
smime.p7s (4.11 kB)
S/MIME Cryptographic Signature

2023-03-22 10:24:20

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next v1] virtio/vsock: check transport before skb allocation

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <[email protected]>:

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 <[email protected]>
> Reviewed-by: Bobby Eshleman <[email protected]>
> Reviewed-by: Stefano Garzarella <[email protected]>
>
> [...]

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html