1
0
Fork 0
alistair23-linux/drivers/virtio
Suman Anna a6ea1df949 virtio_ring: Fix mem leak with vring_new_virtqueue()
commit f13f09a12c upstream.

The functions vring_new_virtqueue() and __vring_new_virtqueue() are used
with split rings, and any allocations within these functions are managed
outside of the .we_own_ring flag. The commit cbeedb72b9 ("virtio_ring:
allocate desc state for split ring separately") allocates the desc state
within the __vring_new_virtqueue() but frees it only when the .we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.

Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.

Fixes: cbeedb72b9 ("virtio_ring: allocate desc state for split ring separately")
Signed-off-by: Suman Anna <s-anna@ti.com>
Link: https://lore.kernel.org/r/20200224212643.30672-1-s-anna@ti.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-18 07:17:55 +01:00
..
Kconfig virtio-pmem: Add virtio pmem driver 2019-07-05 15:19:10 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
virtio.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
virtio_balloon.c virtio_balloon: Adjust label in virtballoon_probe 2020-03-18 07:17:37 +01:00
virtio_input.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
virtio_mmio.c virtio-mmio: add error check for platform_get_irq 2019-07-11 16:22:29 -04:00
virtio_pci_common.c virtio-pci: check name when counting MSI-X vectors 2020-02-11 04:35:43 -08:00
virtio_pci_common.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 78 2019-05-24 17:37:51 +02:00
virtio_pci_legacy.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 78 2019-05-24 17:37:51 +02:00
virtio_pci_modern.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 78 2019-05-24 17:37:51 +02:00
virtio_ring.c virtio_ring: Fix mem leak with vring_new_virtqueue() 2020-03-18 07:17:55 +01:00