diff options
author | Shiraz Hashim <shashim@codeaurora.org> | 2016-03-03 19:49:41 +0530 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-25 16:02:56 -0700 |
commit | 1b7778354b0dab98cc73b854897aa5f81ea6c11b (patch) | |
tree | 4a7c99bef4bdf696758c589836fb34a76e43d31c /mm/zbud.c | |
parent | 35bf07444ad8256a14836f9b2cbf6a14fa041ac4 (diff) |
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>
Diffstat (limited to 'mm/zbud.c')
-rw-r--r-- | mm/zbud.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/zbud.c b/mm/zbud.c index d8a181fd779b..011e42bbf056 100644 --- a/mm/zbud.c +++ b/mm/zbud.c @@ -357,6 +357,7 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, struct zbud_header *zhdr = NULL; enum buddy bud; struct page *page; + int found = 0; if (!size || (gfp & __GFP_HIGHMEM)) return -EINVAL; @@ -376,6 +377,7 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, bud = FIRST; else bud = LAST; + found = 1; goto found; } } @@ -411,6 +413,8 @@ found: list_add(&zhdr->lru, &pool->lru); *handle = encode_handle(zhdr, bud); + if ((gfp & __GFP_ZERO) && found) + memset((void *)*handle, 0, size); spin_unlock(&pool->lock); return 0; |