Skip to content

Commit e602260

Browse files
Andrew MortonLinus Torvalds
authored andcommitted
[PATCH] ext3_clear_inode(): avoid kfree(NULL)
Steven Rostedt <rostedt@goodmis.org> 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 <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 304c4c8 commit e602260

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎fs/ext3/super.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,20 +499,21 @@ static void ext3_clear_inode(struct inode *inode)
499499
{
500500
struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
501501
#ifdef CONFIG_EXT3_FS_POSIX_ACL
502-
if (EXT3_I(inode)->i_acl &&
503-
EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) {
504-
posix_acl_release(EXT3_I(inode)->i_acl);
505-
EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED;
506-
}
507-
if (EXT3_I(inode)->i_default_acl &&
508-
EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) {
509-
posix_acl_release(EXT3_I(inode)->i_default_acl);
510-
EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED;
511-
}
502+
if (EXT3_I(inode)->i_acl &&
503+
EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) {
504+
posix_acl_release(EXT3_I(inode)->i_acl);
505+
EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED;
506+
}
507+
if (EXT3_I(inode)->i_default_acl &&
508+
EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) {
509+
posix_acl_release(EXT3_I(inode)->i_default_acl);
510+
EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED;
511+
}
512512
#endif
513513
ext3_discard_reservation(inode);
514514
EXT3_I(inode)->i_block_alloc_info = NULL;
515-
kfree(rsv);
515+
if (unlikely(rsv))
516+
kfree(rsv);
516517
}
517518

518519
static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb)

0 commit comments

Comments
 (0)