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 <luto at kernel.org> Cc: Michael S. Tsirkin <mst at redhat.com> Cc: stable at vger.kernel.org Signed-off-by: Tiwei Bie <tiwei.bie at intel.com> --- drivers/virtio/virtio_ring.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index eb30f3e09a47..71458f493cf8 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -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); -- 2.11.0
Cornelia Huck
2018-Feb-23 12:47 UTC
[PATCH] virtio_ring: fix num_free handling in error case
On Fri, 23 Feb 2018 19:41:30 +0800 Tiwei Bie <tiwei.bie at intel.com> 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 <luto at kernel.org> > Cc: Michael S. Tsirkin <mst at redhat.com> > Cc: stable at vger.kernel.org > Signed-off-by: Tiwei Bie <tiwei.bie at intel.com> > --- > drivers/virtio/virtio_ring.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index eb30f3e09a47..71458f493cf8 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -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); >Reviewed-by: Cornelia Huck <cohuck at redhat.com>