Skip to content

Commit

Permalink
mm/zsmalloc: allocate exactly size of struct zs_pool
Browse files Browse the repository at this point in the history
In zs_create_pool(), we allocate memory more then sizeof(struct zs_pool)
  ovhd_size = roundup(sizeof(*pool), PAGE_SIZE);

This patch allocate memory of exactly needed size.

Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Ganesh Mahendran authored and Linus Torvalds committed Dec 13, 2014
1 parent df8b5bb commit 1813665
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,11 @@ static bool can_merge(struct size_class *prev, int size, int pages_per_zspage)
*/
struct zs_pool *zs_create_pool(gfp_t flags)
{
int i, ovhd_size;
int i;
struct zs_pool *pool;
struct size_class *prev_class = NULL;

ovhd_size = roundup(sizeof(*pool), PAGE_SIZE);
pool = kzalloc(ovhd_size, GFP_KERNEL);
pool = kzalloc(sizeof(*pool), GFP_KERNEL);
if (!pool)
return NULL;

Expand Down

0 comments on commit 1813665

Please sign in to comment.