Skip to contentSkip to conversation

vhost: fix missing unlock on error in vhost_net_set_features()

PATCH In review Wei Yongjun 2 participants 2 messages Aug 2, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix missing unlock on error in vhost_net_set_features()

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

Fixes eefe82d9b81f ('vhost: new device IOTLB API')
---
 drivers/vhost/net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/vhost/net.c +8 -5
index c6bdd90..5dc128a 100644
@@ -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)
#1 lore raw
Quoted 5 lines · Wei Yongjun

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

Fixes eefe82d9b81f ('vhost: new device IOTLB API')

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

Quoted 37 lines
---
 drivers/vhost/net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/vhost/net.c +8 -5
index c6bdd90..5dc128a 100644
@@ -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)