]> git.baikalelectronics.ru Git - kernel.git/commit
virtio_ring: fix unmap of indirect descriptors
authorMatthias Lange <matthias.lange@kernkonzept.com>
Fri, 6 Sep 2019 14:59:01 +0000 (16:59 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 9 Sep 2019 14:43:15 +0000 (10:43 -0400)
commitd0ab6f2035fb4353ff6144eba04268d1118bff04
tree1bcd78442f26804d5b15643a44eedfdb9c984332
parent61bb4fc77ef0a857d53ea716c3dd7a7fd2d29698
virtio_ring: fix unmap of indirect descriptors

The function virtqueue_add_split() DMA-maps the scatterlist buffers. In
case a mapping error occurs the already mapped buffers must be unmapped.
This happens by jumping to the 'unmap_release' label.

In case of indirect descriptors the release is wrong and may leak kernel
memory. Because the implementation assumes that the head descriptor is
already mapped it starts iterating over the descriptor list starting
from the head descriptor. However for indirect descriptors the head
descriptor is never mapped in case of an error.

The fix is to initialize the start index with zero in case of indirect
descriptors and use the 'desc' pointer directly for iterating over the
descriptor chain.

Signed-off-by: Matthias Lange <matthias.lange@kernkonzept.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_ring.c