ext4: remove quota allocation when ext4_mb_new_blocks fails From: Shen Feng Quota allocation is not removed when ext4_mb_new_blocks calls kmem_cache_alloc failed. Also make sure the allocation context is freed on the error path. Signed-off-by: Shen Feng Signed-off-by: Mingming Cao Signed-off-by: "Theodore Ts'o" --- fs/ext4/mballoc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) Index: linux-2.6.26-rc9/fs/ext4/mballoc.c =================================================================== --- linux-2.6.26-rc9.orig/fs/ext4/mballoc.c 2008-07-11 16:05:01.000000000 -0700 +++ linux-2.6.26-rc9/fs/ext4/mballoc.c 2008-07-11 16:05:02.000000000 -0700 @@ -4056,8 +4056,9 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); if (!ac) { + ar->len = 0; *errp = -ENOMEM; - return 0; + goto out1; } ext4_mb_poll_new_transaction(sb, handle); @@ -4065,7 +4066,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *errp = ext4_mb_initialize_context(ac, ar); if (*errp) { ar->len = 0; - goto out; + goto out2; } ac->ac_op = EXT4_MB_HISTORY_PREALLOC; @@ -4113,11 +4114,12 @@ repeat: ext4_mb_release_context(ac); -out: +out2: + kmem_cache_free(ext4_ac_cachep, ac); +out1: if (ar->len < inquota) DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); - kmem_cache_free(ext4_ac_cachep, ac); return block; } static void ext4_mb_poll_new_transaction(struct super_block *sb,