summaryrefslogtreecommitdiff
path: root/drivers/virtio
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2021-06-04 08:53:49 +0300
committerMichael S. Tsirkin <mst@redhat.com>2021-07-08 14:49:01 +0300
commit5bc72234f7c65830e60806dbb73ae76bacd8a061 (patch)
tree4700d9d62410f8ae288967bc4730e10762daea9a /drivers/virtio
parentfe4c3862df630ec711133e686e023b4467da2ec1 (diff)
downloadlinux-5bc72234f7c65830e60806dbb73ae76bacd8a061.tar.xz
virtio: use err label in __vring_new_virtqueue()
Using error label for unwind in __vring_new_virtqueue. This is useful for future refacotring. Signed-off-by: Jason Wang <jasowang@redhat.com> Link: https://lore.kernel.org/r/20210604055350.58753-7-jasowang@redhat.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_ring.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index c7d9a6fcaee7..5faa876df6c6 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2161,10 +2161,8 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
vq->split.desc_state = kmalloc_array(vring.num,
sizeof(struct vring_desc_state_split), GFP_KERNEL);
- if (!vq->split.desc_state) {
- kfree(vq);
- return NULL;
- }
+ if (!vq->split.desc_state)
+ goto err_state;
/* Put everything in free lists. */
vq->free_head = 0;
@@ -2175,6 +2173,10 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
list_add_tail(&vq->vq.list, &vdev->vqs);
return &vq->vq;
+
+err_state:
+ kfree(vq);
+ return NULL;
}
EXPORT_SYMBOL_GPL(__vring_new_virtqueue);