Skip to contentSkip to conversation

virtio_ring: fix num_free handling in error case

PATCH In review Tiwei Bie 2 participants 2 messages Feb 23, 2018

Subsystems (2)
lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 virtio_ring: fix num_free handling in error case

The vq->vq.num_free hasn't been changed when error happens, so it shouldn't be changed when handling the error.

Fixes 780bc7903a32 ("virtio_ring: Support DMA APIs")
Cc Andy Lutomirski <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 drivers/virtio/virtio_ring.c | 2 --
 1 file changed, 2 deletions(-)
drivers/virtio/virtio_ring.c +0 -2
index eb30f3e09a47..71458f493cf8 100644
@@ -428,8 +428,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
 		i = virtio16_to_cpu(_vq->vdev, vq->vring.desc[i].next);
 	}
 
-	vq->vq.num_free += total_sg;
-
 	if (indirect)
 		kfree(desc);
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · On Fri, 23 Feb 2018 19:41:30 +0800 Tiwei Bie <[email protected]> wrote:

The vq->vq.num_free hasn't been changed when error happens, so it shouldn't be changed when handling the error.

Fixes 780bc7903a32 ("virtio_ring: Support DMA APIs")
Cc Andy Lutomirski <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 drivers/virtio/virtio_ring.c | 2 --
 1 file changed, 2 deletions(-)
drivers/virtio/virtio_ring.c +0 -0
index eb30f3e09a47..71458f493cf8 100644

drivers/virtio/virtio_ring.c static inline int virtqueue_add(struct virtqueue *_vq, · line 433

Quoted 8 lines
drivers/virtio/virtio_ring.c +0 -2
@@ -428,8 +428,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
 		i = virtio16_to_cpu(_vq->vdev, vq->vring.desc[i].next);
 	}
 
-	vq->vq.num_free += total_sg;
-
 	if (indirect)
 		kfree(desc);