Skip to contentSkip to conversation

vsock/virtio: Fix error code in virtio_transport_recv_listen()

PATCH In review Dan Carpenter 3 participants 4 messages Dec 11, 2025

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vsock/virtio: Fix error code in virtio_transport_recv_listen()

Return a negative error code if the transport doesn't match. Don't return success.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---
From static analysis. Not tested.

 net/vmw_vsock/virtio_transport_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +1 -1
index dcc8a1d5851e..77fbc6c541bf 100644
@@ -1550,7 +1550,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		release_sock(child);
 		virtio_transport_reset_no_sock(t, skb);
 		sock_put(child);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	if (virtio_transport_space_update(child, skb))
Signature · 1 line
2.51.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

Return a negative error code if the transport doesn't match. Don't return success.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")
Quoted 21 lines

---

Quoted 1 line

From static analysis. Not tested.

 net/vmw_vsock/virtio_transport_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +1 -1
index dcc8a1d5851e..77fbc6c541bf 100644
@@ -1550,7 +1550,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		release_sock(child);
 		virtio_transport_reset_no_sock(t, skb);
 		sock_put(child);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	if (virtio_transport_space_update(child, skb))
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 17 lines · Dan Carpenter

Return a negative error code if the transport doesn't match. Don't return success.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---
From static analysis. Not tested.

net/vmw_vsock/virtio_transport_common.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +0 -0
index dcc8a1d5851e..77fbc6c541bf 100644

net/vmw_vsock/virtio_transport_common.c virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb, · line 1553

Quoted 5 lines
net/vmw_vsock/virtio_transport_common.c +1 -1
@@ -1550,7 +1550,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		release_sock(child);
 		virtio_transport_reset_no_sock(t, skb);
 		sock_put(child);
-		return ret;
+		return ret ?: -EINVAL;

Thanks for this fix. I think we have a similar issue also in net/vmw_vsock/vmci_transport.c introduced by the same commit. In net/vmw_vsock/hyperv_transport.c we have a similar pattern, but the calling function return void, so no issue there.

Do you mind to fix also that one?

Sending a v2 to fix both or another patch just for that it's fine by me, so:

#3 lore raw
Quoted 29 lines · Stefano Garzarella
Quoted 17 lines · Dan Carpenter

Return a negative error code if the transport doesn't match. Don't return success.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---
From static analysis. Not tested.

net/vmw_vsock/virtio_transport_common.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/virtio_transport_common.c +0 -0
index dcc8a1d5851e..77fbc6c541bf 100644

net/vmw_vsock/virtio_transport_common.c virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb, · line 1553

Quoted 5 lines
net/vmw_vsock/virtio_transport_common.c +1 -1
@@ -1550,7 +1550,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		release_sock(child);
 		virtio_transport_reset_no_sock(t, skb);
 		sock_put(child);
-		return ret;
+		return ret ?: -EINVAL;

Thanks for this fix. I think we have a similar issue also in net/vmw_vsock/vmci_transport.c introduced by the same commit. In net/vmw_vsock/hyperv_transport.c we have a similar pattern, but the calling function return void, so no issue there.

Quoted 1 line

Do you mind to fix also that one?

Sure. I will resend a v2.

The check doesn't catch that one because the != comparison is hidden inside the vmci_check_transport() call. So I would have missed it. Thanks for catching it.

regards,
dan carpenter