[PATCH 1/2] mm, slob: Prevent false positive trace upon allocation failure

Ezequiel Garcia
2012-08-14T14:39:04Z

This patch changes the __kmalloc_node() logic to return NULL
if alloc_pages() fails to return valid pages.
This is done to avoid to trace a false positive kmalloc event.

Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Glauber Costa <glommer@parallels.com>
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
---
mm/slob.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index 45d4ca7..686e98b 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -450,15 +450,16 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
size, size + align, gfp, node);
} else {
unsigned int order = get_order(size);
+ struct page *page;

if (likely(order))
gfp |= __GFP_COMP;
ret = slob_new_pages(gfp, order, node);
- if (ret) {
- struct page *page;
- page = virt_to_page(ret);
- page->private = size;
- }
+ if (!ret)
+ return NULL;
+
+ page = virt_to_page(ret);
+ page->private = size;

trace_kmalloc_node(_RET_IP_, ret,
size, PAGE_SIZE << order, gfp, node);
--
1.7.8.6