virtio_ring: Fix two use after free bugs
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 4 Dec 2020 14:23:36 +0000 (17:23 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 18 Dec 2020 21:14:31 +0000 (16:14 -0500)
commite152d8af4220a05c9797591609151d404866beaa
tree743cd19be076a1bd787c3202dd611e86553843e9
parent411ea23a76526e6efed0b601abb603d3c981b333
virtio_ring: Fix two use after free bugs

The "vq" struct is added to the "vdev->vqs" list prematurely.  If we
encounter an error later in the function then the "vq" is freed, but
since it is still on the list that could lead to a use after free bug.

Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring separately")
Reported-by: Robert Buhren <robert.buhren@sect.tu-berlin.de>
Reported-by: Felicitas Hetzelt <file@sect.tu-berlin.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X8pGaG/zkI3jk8mk@mwanda
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/virtio/virtio_ring.c