virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yongjun <weiyj.lk@gmail.com>
To: "Michael S . Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>
Cc: Wei Yongjun <weiyj.lk@gmail.com>,
	kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features()
Date: Tue,  2 Aug 2016 13:50:10 +0000	[thread overview]
Message-ID: <1470145810-17513-1-git-send-email-weiyj.lk@gmail.com> (raw)

Add the missing unlock before return from function
vhost_net_set_features() in the error handling case.

Fixes: eefe82d9b81f ('vhost: new device IOTLB API')
Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
---
 drivers/vhost/net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index c6bdd90..5dc128a 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1104,13 +1104,12 @@ static int vhost_net_set_features(struct vhost_net *n, u64 features)
 	}
 	mutex_lock(&n->dev.mutex);
 	if ((features & (1 << VHOST_F_LOG_ALL)) &&
-	    !vhost_log_access_ok(&n->dev)) {
-		mutex_unlock(&n->dev.mutex);
-		return -EFAULT;
-	}
+	    !vhost_log_access_ok(&n->dev))
+		goto out_unlock;
+
 	if ((features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) {
 		if (vhost_init_device_iotlb(&n->dev, true))
-			return -EFAULT;
+			goto out_unlock;
 	}
 
 	for (i = 0; i < VHOST_NET_VQ_MAX; ++i) {
@@ -1122,6 +1121,10 @@ static int vhost_net_set_features(struct vhost_net *n, u64 features)
 	}
 	mutex_unlock(&n->dev.mutex);
 	return 0;
+
+out_unlock:
+	mutex_unlock(&n->dev.mutex);
+	return -EFAULT;
 }
 
 static long vhost_net_set_owner(struct vhost_net *n)

             reply	other threads:[~2016-08-02 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 13:50 Wei Yongjun [this message]
2016-08-02 13:52 ` [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features() Michael S. Tsirkin

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=1470145810-17513-1-git-send-email-weiyj.lk@gmail.com \
    --to=weiyj.lk@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --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).