aboutsummaryrefslogtreecommitdiffstats
path: root/mm/zbud.c
diff options
context:
space:
mode:
authorHeesub Shin <heesub.shin@samsung.com>2013-07-31 16:53:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-31 17:41:03 -0400
commit9d8c5b5284e4a0167c5f7b1193692492358b8700 (patch)
treece4fa52666297238d217ce096f5fc6201bd08343 /mm/zbud.c
parente180cf806a93ea1abbce47b245d25204ff557ce9 (diff)
mm: zbud: fix condition check on allocation size
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 <heesub.shin@samsung.com> Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Cc: Bob Liu <bob.liu@oracle.com> Cc: Dongjun Shin <d.j.shin@samsung.com> Cc: Sunae Seo <sunae.seo@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/zbud.c')
-rw-r--r--mm/zbud.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/zbud.c b/mm/zbud.c
index 9bb4710e3589..ad1e781284fd 100644
--- a/mm/zbud.c
+++ b/mm/zbud.c
@@ -257,7 +257,7 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp,
257 257
258 if (size <= 0 || gfp & __GFP_HIGHMEM) 258 if (size <= 0 || gfp & __GFP_HIGHMEM)
259 return -EINVAL; 259 return -EINVAL;
260 if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED) 260 if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE)
261 return -ENOSPC; 261 return -ENOSPC;
262 chunks = size_to_chunks(size); 262 chunks = size_to_chunks(size);
263 spin_lock(&pool->lock); 263 spin_lock(&pool->lock);