]> git.baikalelectronics.ru Git - kernel.git/commitdiff
virtio-balloon: Fix memory leak when unloading while hinting is in progress
authorDavid Hildenbrand <david@redhat.com>
Wed, 5 Feb 2020 16:34:00 +0000 (17:34 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 6 Feb 2020 08:40:26 +0000 (03:40 -0500)
When unloading the driver while hinting is in progress, we will not
release the free page blocks back to MM, resulting in a memory leak.

Fixes: 074bd7f3d238 ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Wei Wang <wei.w.wang@intel.com>
Cc: Liang Li <liang.z.li@intel.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20200205163402.42627-2-david@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_balloon.c

index 2457c54b6185f6de5b8f32a798c292a777ce1e14..6d063eeaa08abf714feb4b5fb1a846c07d73d714 100644 (file)
@@ -970,6 +970,10 @@ static void remove_common(struct virtio_balloon *vb)
                leak_balloon(vb, vb->num_pages);
        update_balloon_size(vb);
 
+       /* There might be free pages that are being reported: release them. */
+       if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
+               return_free_pages_to_mm(vb, ULONG_MAX);
+
        /* Now we reset the device so we can clean up the queues. */
        vb->vdev->config->reset(vb->vdev);