Skip to contentSkip to conversation

Add flag __GFP_NOFAIL when allocating block

PATCH In review Zhang, Yanmin 2 participants 2 messages Sep 29, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add flag __GFP_NOFAIL when allocating block

From: Zhang, Yanmin <[email protected]>

Function journal_write_metadata_buffer doesn't estimate the return value of jbd_slab_alloc. If the allocation fails, later jbd_slab_free or memcpy will cause kernel oops.

Add flag __GFP_NOFAIL when allocating block. The patch is against 2.6.18-mm1.

---

fs/jbd/journal.c +1 -1
@@ -329,7 +329,7 @@ repeat:
 		char *tmp;
 
 		jbd_unlock_bh_state(bh_in);
-		tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS);
+		tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS|__GFP_NOFAIL);
 		jbd_lock_bh_state(bh_in);
 		if (jh_in->b_frozen_data) {
 			jbd_slab_free(tmp, bh_in->b_size);
#1 lore raw
Quoted 14 lines · Yanmin

Function journal_write_metadata_buffer doesn't estimate the return value of jbd_slab_alloc. If the allocation fails, later jbd_slab_free or memcpy will cause kernel oops.

Add flag __GFP_NOFAIL when allocating block. The patch is against 2.6.18-mm1.

---

fs/jbd/journal.c repeat: · line 332

Quoted 5 lines
fs/jbd/journal.c +1 -1
@@ -329,7 +329,7 @@ repeat:
 		char *tmp;
 
 		jbd_unlock_bh_state(bh_in);
-		tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS);
+		tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS|__GFP_NOFAIL);

jbd_slab_alloc() does that internally.