virtio: fix memory leak of virtio ida cache layers
authorSuman Anna <s-anna@ti.com>
Thu, 17 Sep 2015 00:29:17 +0000 (19:29 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 7 Dec 2015 15:28:01 +0000 (17:28 +0200)
The virtio core uses a static ida named virtio_index_ida for
assigning index numbers to virtio devices during registration.
The ida core may allocate some internal idr cache layers and
an ida bitmap upon any ida allocation, and all these layers are
truely freed only upon the ida destruction. The virtio_index_ida
is not destroyed at present, leading to a memory leak when using
the virtio core as a module and atleast one virtio device is
registered and unregistered.

Fix this by invoking ida_destroy() in the virtio core module
exit.

Cc: stable@vger.kernel.org
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio.c

index b1877d73fa563d6d48f2d55b7958f02daa8d9ad7..7062bb0975a521f1a28125c092c2f0d0bbd35787 100644 (file)
@@ -412,6 +412,7 @@ static int virtio_init(void)
 static void __exit virtio_exit(void)
 {
        bus_unregister(&virtio_bus);
+       ida_destroy(&virtio_index_ida);
 }
 core_initcall(virtio_init);
 module_exit(virtio_exit);
This page took 0.050826 seconds and 5 git commands to generate.