forked from mirrors/linux
		
	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>
This commit is contained in:
		
							parent
							
								
									e180cf806a
								
							
						
					
					
						commit
						9d8c5b5284
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue