aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-10-27 21:30:11 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-10-27 21:30:11 -0400
commit877836905da55e8f2426234f42a89287184949e9 (patch)
treeeecb60e9b55daaf794a3083f9c48fc94e05d4cd2
parentbd2d0210cf22f2bd0cef72eb97cf94fc7d31d8cc (diff)
ext4: Check return value of sb_getblk() and friends
Fail block allocation if sb_getblk() returns NULL. In that case, sb_find_get_block() also likely to fail so that it should skip calling ext4_forget(). Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/inode.c5
-rw-r--r--fs/ext4/mballoc.c2
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 58604fe11f4f..077c3c9c432e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -761,6 +761,11 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
761 * parent to disk. 761 * parent to disk.
762 */ 762 */
763 bh = sb_getblk(inode->i_sb, new_blocks[n-1]); 763 bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
764 if (unlikely(!bh)) {
765 err = -EIO;
766 goto failed;
767 }
768
764 branch[n].bh = bh; 769 branch[n].bh = bh;
765 lock_buffer(bh); 770 lock_buffer(bh);
766 BUFFER_TRACE(bh, "call get_create_access"); 771 BUFFER_TRACE(bh, "call get_create_access");
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index d732ef5a835d..611c866ef3fe 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4537,6 +4537,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
4537 if (!bh) 4537 if (!bh)
4538 tbh = sb_find_get_block(inode->i_sb, 4538 tbh = sb_find_get_block(inode->i_sb,
4539 block + i); 4539 block + i);
4540 if (unlikely(!tbh))
4541 continue;
4540 ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA, 4542 ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
4541 inode, tbh, block + i); 4543 inode, tbh, block + i);
4542 } 4544 }