jbd: Check return value of __getblk()
authorNamhyung Kim <namhyung@gmail.com>
Wed, 13 Oct 2010 08:17:18 +0000 (17:17 +0900)
committerJan Kara <jack@suse.cz>
Wed, 27 Oct 2010 23:30:04 +0000 (01:30 +0200)
Fail journal creation if __getblk() returns NULL.  unlikely() is
added because it is called in a loop and we've been OK without
the check until now.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/jbd/journal.c

index e561176518260c23a595e7b6439d2036ebbf9148..ac1840415a650b063319d55e02384e1b278954dc 100644 (file)
@@ -952,6 +952,8 @@ int journal_create(journal_t *journal)
                if (err)
                        return err;
                bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
+               if (unlikely(!bh))
+                       return -ENOMEM;
                lock_buffer(bh);
                memset (bh->b_data, 0, journal->j_blocksize);
                BUFFER_TRACE(bh, "marking dirty");