Skip to content

Commit

Permalink
Ext3: add necessary check in case IO error happens
Browse files Browse the repository at this point in the history
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: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Wang Shilong authored and Jan Kara committed Jan 21, 2013
1 parent 8d8759e commit 61f43e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
* parent to disk.
*/
bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
if (unlikely(!bh)) {
err = -ENOMEM;
goto failed;
}
branch[n].bh = bh;
lock_buffer(bh);
BUFFER_TRACE(bh, "call get_create_access");
Expand Down Expand Up @@ -717,7 +721,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
BUFFER_TRACE(branch[i].bh, "call journal_forget");
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], num);
Expand Down

0 comments on commit 61f43e6

Please sign in to comment.