mm: zbud: initialize object to 0 on GFP_ZERO
zbud_alloc if returns free object from pool must also initialize it to 0 when asked to do so. The same is already taken care if a fresh object is allocated. CRs-fixed: 979234 Change-Id: Id171edf131df321385fcdcd7660d06da97689e3e Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
This commit is contained in:
parent
35bf07444a
commit
1b7778354b
1 changed files with 4 additions and 0 deletions
|
@ -357,6 +357,7 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
|
||||||
struct zbud_header *zhdr = NULL;
|
struct zbud_header *zhdr = NULL;
|
||||||
enum buddy bud;
|
enum buddy bud;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
if (!size || (gfp & __GFP_HIGHMEM))
|
if (!size || (gfp & __GFP_HIGHMEM))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -376,6 +377,7 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
|
||||||
bud = FIRST;
|
bud = FIRST;
|
||||||
else
|
else
|
||||||
bud = LAST;
|
bud = LAST;
|
||||||
|
found = 1;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,6 +413,8 @@ found:
|
||||||
list_add(&zhdr->lru, &pool->lru);
|
list_add(&zhdr->lru, &pool->lru);
|
||||||
|
|
||||||
*handle = encode_handle(zhdr, bud);
|
*handle = encode_handle(zhdr, bud);
|
||||||
|
if ((gfp & __GFP_ZERO) && found)
|
||||||
|
memset((void *)*handle, 0, size);
|
||||||
spin_unlock(&pool->lock);
|
spin_unlock(&pool->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue