Skip to contentSkip to conversation

virtio_balloon: unlock on error in fill_balloon()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 13, 2012

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

PATCH 1/1 virtio_balloon: unlock on error in fill_balloon()

We recently added locking in fill_balloon() but there was one error path which was missed.

---
Only needed in linux-next.

drivers/virtio/virtio_balloon.c +2 -1
index f70151b..1c50e98 100644
@@ -153,9 +153,10 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
 
 	/* Didn't get any?  Oh well. */
 	if (vb->num_pfns = 0)
-		return;
+		goto unlock;
 
 	tell_host(vb, vb->inflate_vq);
+unlock:
 	mutex_unlock(&vb->balloon_lock);
 }
 
#1 lore raw
Quoted 13 lines · Dan Carpenter

We recently added locking in fill_balloon() but there was one error path which was missed.

---
Only needed in linux-next.

drivers/virtio/virtio_balloon.c +0 -0
index f70151b..1c50e98 100644
@@ -153,9 +153,10 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
 

drivers/virtio/virtio_balloon.c static void fill_balloon(struct virtio_balloon *vb, size_t num) · line 162

Quoted 10 lines
drivers/virtio/virtio_balloon.c +2 -1
 	/* Didn't get any?  Oh well. */
 	if (vb->num_pfns = 0)
-		return;
+		goto unlock;
 
 	tell_host(vb, vb->inflate_vq);
+unlock:
 	mutex_unlock(&vb->balloon_lock);
 }
 

Thanks for the catch Dan.

Andrew has already picked a slightly different (and simpler) fix for this one, though.

---8<--- a/drivers/virtio/virtio_balloon.c~virtio_balloon-introduce-migration-primitives-to-balloon-pages-fix-fix +++ a/drivers/virtio/virtio_balloon.c
@@ -151,13 +151,9 @@ static void fill_balloon(struct virtio_b

                totalram_pages--;
       	}

- /* Didn't get any? Oh well. */
- if (vb->num_pfns = 0) {
- mutex_unlock(&vb->balloon_lock);
- return;
- }
-
- tell_host(vb, vb->inflate_vq);
+ /* Did we get any? */
+ if (vb->num_pfns != 0)

+               tell_host(vb, vb->inflate_vq);
        mutex_unlock(&vb->balloon_lock);

}
---8<---