diff options
author | Arseniy Krasnov <avkrasnov@sberdevices.ru> | 2023-03-26 01:04:50 +0300 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2023-03-28 13:03:50 +0300 |
commit | e3ec366eb0d1d5f7cbe28e747c76180f7d45f00d (patch) | |
tree | b1f15a04c52372e0f22431bf61ff69b1635112bf /net/vmw_vsock | |
parent | b68ffb1b3bee3762f7579bdcc9ca3d415ed0b9b4 (diff) | |
download | linux-e3ec366eb0d1d5f7cbe28e747c76180f7d45f00d.tar.xz |
virtio/vsock: check argument to avoid no effect call
Both of these functions have no effect when input argument is 0, so to
avoid useless spinlock access, check argument before it.
Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/vmw_vsock')
-rw-r--r-- | net/vmw_vsock/virtio_transport_common.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 8c60fc7f94a5..7fc178c3ee07 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -302,6 +302,9 @@ u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 credit) { u32 ret; + if (!credit) + return 0; + spin_lock_bh(&vvs->tx_lock); ret = vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); if (ret > credit) @@ -315,6 +318,9 @@ EXPORT_SYMBOL_GPL(virtio_transport_get_credit); void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit) { + if (!credit) + return; + spin_lock_bh(&vvs->tx_lock); vvs->tx_cnt -= credit; spin_unlock_bh(&vvs->tx_lock); |