diff options
author | Wang Shilong <wangsl-fnst@cn.fujitsu.com> | 2013-01-12 04:22:33 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2013-01-21 05:19:56 -0500 |
commit | 61f43e6880dee5983999fe40bf96c1cf43740b4c (patch) | |
tree | 95ac823e8e7518a8e6fac3a0e2bae4a91a5d6b05 /fs/ext3 | |
parent | 8d8759eb488f9e88fa5f976c4fd7ed205661c872 (diff) |
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: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/inode.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index b176d4253544..6e4f8a529fbc 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -676,6 +676,10 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, | |||
676 | * parent to disk. | 676 | * parent to disk. |
677 | */ | 677 | */ |
678 | bh = sb_getblk(inode->i_sb, new_blocks[n-1]); | 678 | bh = sb_getblk(inode->i_sb, new_blocks[n-1]); |
679 | if (unlikely(!bh)) { | ||
680 | err = -ENOMEM; | ||
681 | goto failed; | ||
682 | } | ||
679 | branch[n].bh = bh; | 683 | branch[n].bh = bh; |
680 | lock_buffer(bh); | 684 | lock_buffer(bh); |
681 | BUFFER_TRACE(bh, "call get_create_access"); | 685 | BUFFER_TRACE(bh, "call get_create_access"); |
@@ -717,7 +721,7 @@ failed: | |||
717 | BUFFER_TRACE(branch[i].bh, "call journal_forget"); | 721 | BUFFER_TRACE(branch[i].bh, "call journal_forget"); |
718 | ext3_journal_forget(handle, branch[i].bh); | 722 | ext3_journal_forget(handle, branch[i].bh); |
719 | } | 723 | } |
720 | for (i = 0; i <indirect_blks; i++) | 724 | for (i = 0; i < indirect_blks; i++) |
721 | ext3_free_blocks(handle, inode, new_blocks[i], 1); | 725 | ext3_free_blocks(handle, inode, new_blocks[i], 1); |
722 | 726 | ||
723 | ext3_free_blocks(handle, inode, new_blocks[i], num); | 727 | ext3_free_blocks(handle, inode, new_blocks[i], num); |