aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@citrix.com>2020-07-27 11:13:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-19 08:16:28 +0200
commitee4c180d93d0c33565c3edd32dbce7760084493b (patch)
tree952564d9bc2d36669b2512476ec5f2208a712b0e
parentdb1f4c745a91c3988c57cefb125c7a01711de5e2 (diff)
downloadlinux-yocto-ee4c180d93d0c33565c3edd32dbce7760084493b.tar.gz
linux-yocto-ee4c180d93d0c33565c3edd32dbce7760084493b.tar.bz2
linux-yocto-ee4c180d93d0c33565c3edd32dbce7760084493b.zip
xen/balloon: fix accounting in alloc_xenballooned_pages error path
commit 1951fa33ec259abdf3497bfee7b63e7ddbb1a394 upstream. target_unpopulated is incremented with nr_pages at the start of the function, but the call to free_xenballooned_pages will only subtract pgno number of pages, and thus the rest need to be subtracted before returning or else accounting will be skewed. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200727091342.52325-2-roger.pau@citrix.com Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/xen/balloon.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index bed90d612e48..d792fa972d96 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -632,6 +632,12 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages)
out_undo:
mutex_unlock(&balloon_mutex);
free_xenballooned_pages(pgno, pages);
+ /*
+ * NB: free_xenballooned_pages will only subtract pgno pages, but since
+ * target_unpopulated is incremented with nr_pages at the start we need
+ * to remove the remaining ones also, or accounting will be screwed.
+ */
+ balloon_stats.target_unpopulated -= nr_pages - pgno;
return ret;
}
EXPORT_SYMBOL(alloc_xenballooned_pages);