]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Ext3: add necessary check in case IO error happens
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>
Sat, 12 Jan 2013 09:22:33 +0000 (01:22 -0800)
committerJan Kara <jack@suse.cz>
Mon, 21 Jan 2013 10:19:56 +0000 (11:19 +0100)
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>
fs/ext3/inode.c

index b176d425354428043ef92c4e680353d90a28c760..6e4f8a529fbcebaebfad5f093d98fcc9601f3e91 100644 (file)
@@ -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 <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);