diff options
author | Roger Pau Monne <roger.pau@citrix.com> | 2020-07-27 12:13:39 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-19 09:15:07 +0300 |
commit | bbe6145f996edb4490ddde31e981dafb1e922917 (patch) | |
tree | cf6489c8da0e740f8cc54d615869249726207320 /drivers/xen | |
parent | 8e22f6848fc80c34ce7e7bf2bdbd5c8fb54e2fe4 (diff) | |
download | linux-bbe6145f996edb4490ddde31e981dafb1e922917.tar.xz |
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>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/balloon.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 6fa7209f24f4..6e89b6ab1d3e 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); |