Skip to content

Commit

Permalink
mm: zbud: fix condition check on allocation size
Browse files Browse the repository at this point in the history
zbud_alloc() incorrectly verifies the size of allocation limit.  It
should deny the allocation request greater than (PAGE_SIZE -
ZHDR_SIZE_ALIGNED - CHUNK_SIZE), not (PAGE_SIZE - ZHDR_SIZE_ALIGNED)
which has no remaining spaces for its buddy.  There is no point in
spending the entire zbud page storing only a single page, since we don't
have any benefits.

Signed-off-by: Heesub Shin <[email protected]>
Acked-by: Seth Jennings <[email protected]>
Cc: Bob Liu <[email protected]>
Cc: Dongjun Shin <[email protected]>
Cc: Sunae Seo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Heesub Shin authored and torvalds committed Jul 31, 2013
1 parent e180cf8 commit 9d8c5b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/zbud.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp,

if (size <= 0 || gfp & __GFP_HIGHMEM)
return -EINVAL;
if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED)
if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE)
return -ENOSPC;
chunks = size_to_chunks(size);
spin_lock(&pool->lock);
Expand Down

0 comments on commit 9d8c5b5

Please sign in to comment.