From: Andrew Morton Date: Fri, 23 Jun 2006 09:05:32 +0000 (-0700) Subject: [PATCH] ext3_clear_inode(): avoid kfree(NULL) X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e6022603b9aa7d61d20b392e69edcdbbc1789969;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PATCH] ext3_clear_inode(): avoid kfree(NULL) Steven Rostedt points out that `rsv' here is usually NULL, so we should avoid calling kfree(). Also, fix up some nearby whitespace damage. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ext3/super.c b/fs/ext3/super.c index e08b6439617c..1a198b3985c9 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -499,20 +499,21 @@ static void ext3_clear_inode(struct inode *inode) { struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; #ifdef CONFIG_EXT3_FS_POSIX_ACL - if (EXT3_I(inode)->i_acl && - EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) { - posix_acl_release(EXT3_I(inode)->i_acl); - EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED; - } - if (EXT3_I(inode)->i_default_acl && - EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) { - posix_acl_release(EXT3_I(inode)->i_default_acl); - EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED; - } + if (EXT3_I(inode)->i_acl && + EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) { + posix_acl_release(EXT3_I(inode)->i_acl); + EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED; + } + if (EXT3_I(inode)->i_default_acl && + EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) { + posix_acl_release(EXT3_I(inode)->i_default_acl); + EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED; + } #endif ext3_discard_reservation(inode); EXT3_I(inode)->i_block_alloc_info = NULL; - kfree(rsv); + if (unlikely(rsv)) + kfree(rsv); } static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb)