Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen/balloon: fix accounting in alloc_xenballooned_pages error path

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>

authored by

Roger Pau Monne and committed by
Juergen Gross
1951fa33 4e722d4f

+6
+6
drivers/xen/balloon.c
··· 630 630 out_undo: 631 631 mutex_unlock(&balloon_mutex); 632 632 free_xenballooned_pages(pgno, pages); 633 + /* 634 + * NB: free_xenballooned_pages will only subtract pgno pages, but since 635 + * target_unpopulated is incremented with nr_pages at the start we need 636 + * to remove the remaining ones also, or accounting will be screwed. 637 + */ 638 + balloon_stats.target_unpopulated -= nr_pages - pgno; 633 639 return ret; 634 640 } 635 641 EXPORT_SYMBOL(alloc_xenballooned_pages);