Skip to contentSkip to conversation

jbd: replace potentially false assertion with if block

PATCH In review [email protected] 1 participant 1 message Jul 25, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 63/283 jbd: replace potentially false assertion with if block

From: "Duane Griffin" <[email protected]>

If an error occurs during jbd cache initialisation it is possible for the journal_head_cache to be NULL when journal_destroy_journal_head_cache is called. Replace the J_ASSERT with an if block to handle the situation correctly.

Note that even with this fix things will break badly if jbd is statically compiled in and cache initialisation fails.

---

 fs/jbd/journal.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/jbd/journal.c renamed from fs/jbd/journal.c~jbd-replace-potentially-false-assertion-with-if-block +4 -3
diff -puN fs/jbd/journal.c~jbd-replace-potentially-false-assertion-with-if-block fs/jbd/journal.c
@@ -1636,9 +1636,10 @@ static int journal_init_journal_head_cac
 
 static void journal_destroy_journal_head_cache(void)
 {
-	J_ASSERT(journal_head_cache != NULL);
-	kmem_cache_destroy(journal_head_cache);
-	journal_head_cache = NULL;
+	if (journal_head_cache) {
+		kmem_cache_destroy(journal_head_cache);
+		journal_head_cache = NULL;
+	}
 }
 
 /*

_