Skip to content

Commit

Permalink
virtio: use err label in __vring_new_virtqueue()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jason Wang authored and Michael S. Tsirkin committed Jul 8, 2021
1 parent fe4c386 commit 5bc7223
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 5bc7223

Please sign in to comment.