Commit 5bc72234 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

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: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210604055350.58753-7-jasowang@redhat.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent fe4c3862
...@@ -2161,10 +2161,8 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, ...@@ -2161,10 +2161,8 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
vq->split.desc_state = kmalloc_array(vring.num, vq->split.desc_state = kmalloc_array(vring.num,
sizeof(struct vring_desc_state_split), GFP_KERNEL); sizeof(struct vring_desc_state_split), GFP_KERNEL);
if (!vq->split.desc_state) { if (!vq->split.desc_state)
kfree(vq); goto err_state;
return NULL;
}
/* Put everything in free lists. */ /* Put everything in free lists. */
vq->free_head = 0; vq->free_head = 0;
...@@ -2175,6 +2173,10 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, ...@@ -2175,6 +2173,10 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
list_add_tail(&vq->vq.list, &vdev->vqs); list_add_tail(&vq->vq.list, &vdev->vqs);
return &vq->vq; return &vq->vq;
err_state:
kfree(vq);
return NULL;
} }
EXPORT_SYMBOL_GPL(__vring_new_virtqueue); EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment