summaryrefslogtreecommitdiffstats
path: root/fs/jbd/journal.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-07-15 20:36:08 +0200
committerJan Kara <jack@suse.cz>2009-07-15 21:26:23 +0200
commit7447a668a3860b66b3c9db86fdea91e355ba59ac (patch)
treef27e2c1df19e6558bce053e8ffa12bd121a30947 /fs/jbd/journal.c
parente9e961c9a818a2f24711af493b907a8e40a69efc (diff)
jbd: Fail to load a journal if it is too short
Due to on disk corruption, it can happen that journal is too short. Fail to load it in such case so that we don't oops somewhere later. Reported-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/jbd/journal.c')
-rw-r--r--fs/jbd/journal.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 737f7246a4b..94a64a199a6 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -848,6 +848,12 @@ static int journal_reset(journal_t *journal)
first = be32_to_cpu(sb->s_first);
last = be32_to_cpu(sb->s_maxlen);
+ if (first + JFS_MIN_JOURNAL_BLOCKS > last + 1) {
+ printk(KERN_ERR "JBD: Journal too short (blocks %lu-%lu).\n",
+ first, last);
+ journal_fail_superblock(journal);
+ return -EINVAL;
+ }
journal->j_first = first;
journal->j_last = last;