[PATCH v22.11] vhost: fix missing spinlock unlock
Xueming(Steven) Li
xuemingl at nvidia.com
Thu Jan 11 12:11:01 CET 2024
Thanks Maxime!
Hailin, could you please confirm if it fixes https://bugs.dpdk.org/show_bug.cgi?id=1338?
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin at redhat.com>
> Sent: 1/11/2024 18:52
> To: stable at dpdk.org; Xueming(Steven) Li <xuemingl at nvidia.com>;
> ktraynor at redhat.com; dmarchan at redhat.com
> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>
> Subject: [PATCH v22.11] vhost: fix missing spinlock unlock
>
> Two regressions were introduced when backporting below
> patch:
> b4c4e5675c85 ("vhost: fix missing lock protection in power monitor API")
>
> First, rte_vhost_get_monitor_addr did not release the lock in the success case.
> Then, rte_rwlock_read_lock() was converted to rte_spinlock_trylock() instead of
> rte_spinlock_lock().
>
> This patch addresses both of these issues.
>
> Fixes: a07736eb68da ("vhost: fix missing lock protection in power monitor API")
> Cc: stable at dpdk.org
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
> lib/vhost/vhost.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 40ac350e21..9e28198528
> 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -2060,6 +2060,7 @@ rte_vhost_get_monitor_addr(int vid, uint16_t
> queue_id, {
> struct virtio_net *dev = get_device(vid);
> struct vhost_virtqueue *vq;
> + int ret = 0;
>
> if (dev == NULL)
> return -1;
> @@ -2070,11 +2071,12 @@ rte_vhost_get_monitor_addr(int vid, uint16_t
> queue_id,
> if (vq == NULL)
> return -1;
>
> - if (!rte_spinlock_trylock(&vq->access_lock))
> - return -1;
> + rte_spinlock_lock(&vq->access_lock);
>
> - if (unlikely(!vq->access_ok))
> + if (unlikely(!vq->access_ok)) {
> + ret = -1;
> goto out_unlock;
> + }
>
> if (vq_is_packed(dev)) {
> struct vring_packed_desc *desc;
> @@ -2095,12 +2097,10 @@ rte_vhost_get_monitor_addr(int vid, uint16_t
> queue_id,
> pmc->match = 0;
> }
>
> - return 0;
> -
> out_unlock:
> rte_spinlock_unlock(&vq->access_lock);
>
> - return -1;
> + return ret;
> }
>
>
> --
> 2.43.0
More information about the stable
mailing list