drm/amd/display: Implement bounds check for stream encoder creation in DCN301
[platform/kernel/linux-starfive.git] / drivers / virtio / virtio_balloon.c
index 5b15936..2d5d252 100644 (file)
@@ -395,7 +395,11 @@ static inline s64 towards_target(struct virtio_balloon *vb)
        virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages,
                        &num_pages);
 
-       target = num_pages;
+       /*
+        * Aligned up to guest page size to avoid inflating and deflating
+        * balloon endlessly.
+        */
+       target = ALIGN(num_pages, VIRTIO_BALLOON_PAGES_PER_PAGE);
        return target - vb->num_pages;
 }