virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features()
@ 2016-08-02 13:50 Wei Yongjun
  2016-08-02 13:52 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2016-08-02 13:50 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang; +Cc: Wei Yongjun, kvm, virtualization

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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features()
  2016-08-02 13:50 [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features() Wei Yongjun
@ 2016-08-02 13:52 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2016-08-02 13:52 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: kvm, virtualization

On Tue, Aug 02, 2016 at 01:50:10PM +0000, Wei Yongjun wrote:
> 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>

Thanks!
I'll squash this into the offending commit.

> ---
>  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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-02 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 13:50 [PATCH -next] vhost: fix missing unlock on error in vhost_net_set_features() Wei Yongjun
2016-08-02 13:52 ` Michael S. Tsirkin

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).