Commit 33278f7f authored by Namhyung Kim's avatar Namhyung Kim Committed by Linus Torvalds

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: default avatarNamhyung Kim <namhyung@gmail.com>
Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: default avatarBalbir Singh <balbir@linux.vnet.ibm.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 268433b8
...@@ -475,7 +475,7 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) ...@@ -475,7 +475,7 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
if (!do_swap_account) if (!do_swap_account)
return 0; return 0;
length = ((max_pages/SC_PER_PAGE) + 1); length = DIV_ROUND_UP(max_pages, SC_PER_PAGE);
array_size = length * sizeof(void *); array_size = length * sizeof(void *);
array = vmalloc(array_size); array = vmalloc(array_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment