lkml.org 
[lkml]   [2010]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] lib/btree: Fix possible NULL pointer dereference
mempool_alloc can return null in atomic case.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
---
diff --git a/lib/btree.c b/lib/btree.c
index 41859a8..542c904 100644
--- a/lib/btree.c
+++ b/lib/btree.c
@@ -95,7 +94,8 @@ static unsigned long *btree_node_alloc(struct btree_head *head, gfp_t gfp)
unsigned long *node;

node = mempool_alloc(head->mempool, gfp);
- memset(node, 0, NODESIZE);
+ if (likely(node))
+ memset(node, 0, NODESIZE);
return node;
}


\
 
 \ /
  Last update: 2010-05-12 23:20    [W:0.026 / U:7.352 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site