Skip to contentSkip to conversation

Fix memory leak when the ext3's journal file is corrupted

PATCH In review Theodore Ts'o 2 participants 2 messages May 22, 2006 – May 23, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix memory leak when the ext3's journal file is corrupted

Fix memory leak when the ext3's journal file is corrupted

fs/jbd/recovery.c +1 -0
Index: linux-2.6/fs/jbd/recovery.c
===================================================================
@@ -531,6 +531,7 @@
 		default:
 			jbd_debug(3, "Unrecognised magic %d, end of scan.\n",
 				  blocktype);
+			brelse(bh);
 			goto done;
 		}
 	}
#1 lore raw

Hi Theodore,

Quoted 10 lines · Theodore Ts'o

Fix memory leak when the ext3's journal file is corrupted

Index: linux-2.6/fs/jbd/recovery.c
===================================================================

fs/jbd/recovery.c line 537

Quoted 7 lines
fs/jbd/recovery.c +1 -0
@@ -531,6 +531,7 @@
 		default:
 			jbd_debug(3, "Unrecognised magic %d, end of scan.\n",
 				  blocktype);
+			brelse(bh);
 			goto done;
 		}
 	}

It seems to me that this one is a clear candidate for 2.4 too, isn't it ? While reviewing diffs between 2.4 and 2.6 on this file, I also found this patch from Andrew two years ago which also seems appropriate for 2.4 :

[PATCH] JBD: avoid panic on corrupted journal superblock

Don't panic if the journal superblock is wrecked: just fail the mount.

fs/jbd/recovery.c +4 -1
@@ -137,7 +137,10 @@
 
 	*bhp = NULL;
 
-	J_ASSERT (offset < journal->j_maxlen);
+	if (offset >= journal->j_maxlen) {
+		printk(KERN_ERR "JBD: corrupted journal superblock\n");
+		return -EIO;
+	}
 
 	err = journal_bmap(journal, offset, &blocknr);
 

I'm about to queue them both for Marcelo, do you have any objection ?

Thanks in advance,
Willy