diff mbox series

[RFC,v1] virtio/vsock: check transport before skb allocation

Message ID 47a7dbf6-1c63-3338-5102-122766e6378d@sberdevices.ru (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [RFC,v1] virtio/vsock: check transport before skb allocation | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be 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 17, 2023, 10:37 a.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>
---
 net/vmw_vsock/virtio_transport_common.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Bobby Eshleman March 17, 2023, 9:54 p.m. UTC | #1
On Fri, Mar 17, 2023 at 01:37:10PM +0300, Arseniy Krasnov 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>
> ---
>  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

LGTM.

Reviewed-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
Stefano Garzarella March 20, 2023, 1:58 p.m. UTC | #2
On Fri, Mar 17, 2023 at 01:37:10PM +0300, Arseniy Krasnov 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>
>---
> net/vmw_vsock/virtio_transport_common.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)

LGTM, I think net-next is fine for this.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

Thanks,
Stefano

>
>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
>
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);
 }