jbd2: Add error check to journal_wait_on_commit_record to avoid oops
authorMingming Cao <cmm@u.ibm.com>
Tue, 5 Feb 2008 13:52:45 +0000 (08:52 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Feb 2008 13:52:45 +0000 (08:52 -0500)
The buffer head pointer passed to journal_wait_on_commit_record() could
be NULL if the previous journal_submit_commit_record() failed or journal
has already aborted.

Looking at the jbd2 debug messages, before the oops happened, the jbd2
is aborted due to trying to access the next log block beyond the end
of device. This might be caused by using a corrupted image.

We need to check the error returns from journal_submit_commit_record()
and avoid calling journal_wait_on_commit_record() in the failure case.

This addresses Kernel Bugzilla #9849

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/jbd2/commit.c

index 4f302d2792794008351326bf9d6e128cf8b18a33..48b3cb8aeb2e380a79897b96ec5b809705eb726c 100644 (file)
@@ -872,7 +872,8 @@ wait_for_iobuf:
                if (err)
                        __jbd2_journal_abort_hard(journal);
        }
-       err = journal_wait_on_commit_record(cbh);
+       if (!err && !is_journal_aborted(journal))
+               err = journal_wait_on_commit_record(cbh);
 
        if (err)
                jbd2_journal_abort(journal, err);