Commit 61f43e68 authored by Wang Shilong's avatar Wang Shilong Committed by Jan Kara

Ext3: add necessary check in case IO error happens

As we know io error may happen when the function 'sb_getblk'
is called.Add necessary check for it

The patch also fix a coding style problem.
Signed-off-by: default avatarWang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 8d8759eb
...@@ -676,6 +676,10 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, ...@@ -676,6 +676,10 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
* parent to disk. * parent to disk.
*/ */
bh = sb_getblk(inode->i_sb, new_blocks[n-1]); bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
if (unlikely(!bh)) {
err = -ENOMEM;
goto failed;
}
branch[n].bh = bh; branch[n].bh = bh;
lock_buffer(bh); lock_buffer(bh);
BUFFER_TRACE(bh, "call get_create_access"); BUFFER_TRACE(bh, "call get_create_access");
...@@ -717,7 +721,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, ...@@ -717,7 +721,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
BUFFER_TRACE(branch[i].bh, "call journal_forget"); BUFFER_TRACE(branch[i].bh, "call journal_forget");
ext3_journal_forget(handle, branch[i].bh); ext3_journal_forget(handle, branch[i].bh);
} }
for (i = 0; i <indirect_blks; i++) for (i = 0; i < indirect_blks; i++)
ext3_free_blocks(handle, inode, new_blocks[i], 1); ext3_free_blocks(handle, inode, new_blocks[i], 1);
ext3_free_blocks(handle, inode, new_blocks[i], num); ext3_free_blocks(handle, inode, new_blocks[i], num);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment