2010-10-13 08:17:26

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH] jbd: Check return value of __getblk()

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 <[email protected]>
---
fs/jbd/journal.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 7fee247..3290fe9 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -950,6 +950,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");
--
1.7.0.4



2010-10-14 10:23:17

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] jbd: Check return value of __getblk()

On Wed 13-10-10 17:17:18, Namhyung Kim wrote:
> 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.
Thanks. Merged.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR