diff options
author | David Hildenbrand <[email protected]> | 2020-02-05 17:34:00 +0100 |
---|---|---|
committer | Michael S. Tsirkin <[email protected]> | 2020-02-06 03:40:26 -0500 |
commit | 6c22dc61c76b7e7d355f1697ba0ecf26d1334ba6 (patch) | |
tree | 6b85e47f905472c5a1e1c5c54d9391936562fd7a | |
parent | 6e9826e77249355c09db6ba41cd3f84e89f4b614 (diff) |
virtio-balloon: Fix memory leak when unloading while hinting is in progress
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: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Wei Wang <[email protected]>
Cc: Liang Li <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 2457c54b6185..6d063eeaa08a 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -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); |