[PATCH net-next] vsock: remove unnecessary null check in vsock_getname()

Wang Liang posted 1 patch 2 months, 1 week ago
net/vmw_vsock/af_vsock.c | 5 -----
1 file changed, 5 deletions(-)
[PATCH net-next] vsock: remove unnecessary null check in vsock_getname()
Posted by Wang Liang 2 months, 1 week ago
The local variable 'vm_addr' is always not NULL, no need to check it.

Signed-off-by: Wang Liang <wangliang74@huawei.com>
---
 net/vmw_vsock/af_vsock.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 1053662725f8..fae512594849 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1028,11 +1028,6 @@ static int vsock_getname(struct socket *sock,
 		vm_addr = &vsk->local_addr;
 	}
 
-	if (!vm_addr) {
-		err = -EINVAL;
-		goto out;
-	}
-
 	/* sys_getsockname() and sys_getpeername() pass us a
 	 * MAX_SOCK_ADDR-sized buffer and don't set addr_len.  Unfortunately
 	 * that macro is defined in socket.c instead of .h, so we hardcode its
-- 
2.34.1
Re: [PATCH net-next] vsock: remove unnecessary null check in vsock_getname()
Posted by Stefano Garzarella 2 months, 1 week ago
On Fri, Jul 25, 2025 at 09:38:08AM +0800, Wang Liang wrote:
>The local variable 'vm_addr' is always not NULL, no need to check it.
>
>Signed-off-by: Wang Liang <wangliang74@huawei.com>
>---
> net/vmw_vsock/af_vsock.c | 5 -----
> 1 file changed, 5 deletions(-)

Thanks for the cleanup! We've had it since the beginning, maybe some 
changes were made during initial development...

LGTM!

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

>
>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>index 1053662725f8..fae512594849 100644
>--- a/net/vmw_vsock/af_vsock.c
>+++ b/net/vmw_vsock/af_vsock.c
>@@ -1028,11 +1028,6 @@ static int vsock_getname(struct socket *sock,
> 		vm_addr = &vsk->local_addr;
> 	}
>
>-	if (!vm_addr) {
>-		err = -EINVAL;
>-		goto out;
>-	}
>-
> 	/* sys_getsockname() and sys_getpeername() pass us a
> 	 * MAX_SOCK_ADDR-sized buffer and don't set addr_len.  Unfortunately
> 	 * that macro is defined in socket.c instead of .h, so we hardcode its
>-- 
>2.34.1
>
>