[PATCH] JBD: avoid panic on corrupted journal superblock (from akpm)

Linux Kernel Mailing List <[email protected]> Fri, 26 May 2006 19:59:02 GMT
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
commit 6601095e2de35f00325a33c8be6b548f81fe76d5
tree eb0c44c6e7f5d5cb2f4eaac315cb048dbfa17809
parent 2c7a224a52bcd4917c9de109eced3a036af6fa87
author Willy TARREAU <willy@pcw.(none)> Mon, 22 May 2006 03:08:34 -0400
committer Marcelo Tosatti <[email protected]> Fri, 26 May 2006 22:35:58 -0300

[PATCH] JBD: avoid panic on corrupted journal superblock (from akpm)

Initial patch from Andrew Morton merged into 2.6 :
Don't panic if the journal superblock is wrecked: just fail the mount.

 fs/jbd/recovery.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c
index c02a0ef..d18df61 100644
--- a/fs/jbd/recovery.c
+++ b/fs/jbd/recovery.c
@@ -138,8 +138,11 @@ static int jread(struct buffer_head **bh
 
 	*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);
 
 	if (err) {