Skip to contentSkip to conversation

Improve prepare_bnode ENOMEM handling

PATCH New Laurent Riffard 1 participant 1 message May 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve prepare_bnode ENOMEM handling

If prepare_bnode fails to allocate memory, it should return null pointers because callers will try to release allocated memory (ie non-null pointers).

---
 fs/reiser4/plugin/space/bitmap.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)
fs/reiser4/plugin/space/bitmap.c +5 -1
Index: linux-2.6-mm/fs/reiser4/plugin/space/bitmap.c
===================================================================
@@ -741,9 +741,13 @@ prepare_bnode(struct bitmap_node *bnode,
 
 	super = reiser4_get_current_sb();
 
+	/* Callers have to release allocated memory for cjnode an wjnode even
+	 * if we return an error code. */
 	*wjnode_ret = wjnode = bnew();
-	if (wjnode == NULL)
+	if (wjnode == NULL) {
+		*cjnode_ret = NULL;
 		return RETERR(-ENOMEM);
+	}
 
 	*cjnode_ret = cjnode = bnew();
 	if (cjnode == NULL)

--