From: Wang Shilong Date: Sat, 12 Jan 2013 09:22:33 +0000 (-0800) Subject: Ext3: add necessary check in case IO error happens X-Git-Tag: v3.9-rc1~65^2~12 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=61f43e6880dee5983999fe40bf96c1cf43740b4c;p=linux-block.git 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 Signed-off-by: Jan Kara --- 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, * 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"); @@ -717,7 +721,7 @@ failed: BUFFER_TRACE(branch[i].bh, "call journal_forget"); ext3_journal_forget(handle, branch[i].bh); } - for (i = 0; i