From: Jia He <justin.he@arm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Kaly.Xin@arm.com, Jia He <justin.he@arm.com>
Subject: [PATCH] vhost: add mutex_lock/unlock for vhost_vq_reset
Date: Thu, 30 Apr 2020 10:41:40 +0800 [thread overview]
Message-ID: <20200430024140.42065-1-justin.he@arm.com> (raw)
vq->mutex is to protect any vq accessing, hence adding mutex_lock/unlock
makes sense to avoid potential race condition.
Signed-off-by: Jia He <justin.he@arm.com>
---
drivers/vhost/vhost.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index d450e16c5c25..622bfba2e5ab 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -297,6 +297,7 @@ static void vhost_vq_meta_reset(struct vhost_dev *d)
static void vhost_vq_reset(struct vhost_dev *dev,
struct vhost_virtqueue *vq)
{
+ mutex_lock(&vq->mutex);
vq->num = 1;
vq->desc = NULL;
vq->avail = NULL;
@@ -323,6 +324,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
vq->umem = NULL;
vq->iotlb = NULL;
__vhost_vq_meta_reset(vq);
+ mutex_unlock(&vq->mutex);
}
static int vhost_worker(void *data)
--
2.17.1
reply other threads:[~2020-04-30 2:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200430024140.42065-1-justin.he@arm.com \
--to=justin.he@arm.com \
--cc=Kaly.Xin@arm.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).