From: Namhyung Kim Date: Thu, 26 May 2011 23:25:30 +0000 (-0700) Subject: memcg: fix off-by-one when calculating swap cgroup map length X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=33278f7f0a9e5a9b29f59e07b7e3182d27769ac2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git memcg: fix off-by-one when calculating swap cgroup map length It allocated one more page than necessary if @max_pages was a multiple of SC_PER_PAGE. Signed-off-by: Namhyung Kim Acked-by: KAMEZAWA Hiroyuki Acked-by: Balbir Singh Cc: Daisuke Nishimura Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 4eb05302e2e1..5524e8bd7437 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c @@ -475,7 +475,7 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) if (!do_swap_account) return 0; - length = ((max_pages/SC_PER_PAGE) + 1); + length = DIV_ROUND_UP(max_pages, SC_PER_PAGE); array_size = length * sizeof(void *); array = vmalloc(array_size);