vsock/virtio: Fix error code in virtio_transport_recv_listen()
Subsystems (7)
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.
---
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
@@ -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
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")Signed-off-by Dan Carpenter <[email protected]>
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@@ -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
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")Signed-off-by Dan Carpenter <[email protected]>---
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
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:
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")Signed-off-by Dan Carpenter <[email protected]>---
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
-0net/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.cintroduced by the same commit. Innet/vmw_vsock/hyperv_transport.cwe 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