Jesper Juhl
2005-Mar-25 22:11 UTC
[PATCH] kfree() NULL pointer cleanups - no need to check - fs/ext3/
kfree() handles NULL pointers fine - checking is redundant. Signed-off-by: Jesper Juhl <juhl-lkml at dif.dk> --- linux-2.6.12-rc1-mm3-orig/fs/ext3/acl.c 2005-03-02 08:37:55.000000000 +0100 +++ linux-2.6.12-rc1-mm3/fs/ext3/acl.c 2005-03-25 22:41:41.000000000 +0100 @@ -197,8 +197,7 @@ ext3_get_acl(struct inode *inode, int ty acl = NULL; else acl = ERR_PTR(retval); - if (value) - kfree(value); + kfree(value); if (!IS_ERR(acl)) { switch(type) { @@ -267,8 +266,7 @@ ext3_set_acl(handle_t *handle, struct in error = ext3_xattr_set_handle(handle, inode, name_index, "", value, size, 0); - if (value) - kfree(value); + kfree(value); if (!error) { switch(type) { case ACL_TYPE_ACCESS: --- linux-2.6.12-rc1-mm3-orig/fs/ext3/super.c 2005-03-25 15:28:59.000000000 +0100 +++ linux-2.6.12-rc1-mm3/fs/ext3/super.c 2005-03-25 22:42:53.000000000 +0100 @@ -395,10 +395,8 @@ static void ext3_put_super (struct super percpu_counter_destroy(&sbi->s_dirs_counter); brelse(sbi->s_sbh); #ifdef CONFIG_QUOTA - for (i = 0; i < MAXQUOTAS; i++) { - if (sbi->s_qf_names[i]) - kfree(sbi->s_qf_names[i]); - } + for (i = 0; i < MAXQUOTAS; i++) + kfree(sbi->s_qf_names[i]); #endif /* Debugging code just in case the in-memory inode orphan list @@ -883,10 +881,8 @@ clear_qf_name: "quota turned on.\n"); return 0; } - if (sbi->s_qf_names[qtype]) { - kfree(sbi->s_qf_names[qtype]); - sbi->s_qf_names[qtype] = NULL; - } + kfree(sbi->s_qf_names[qtype]); + sbi->s_qf_names[qtype] = NULL; break; case Opt_jqfmt_vfsold: sbi->s_jquota_fmt = QFMT_VFS_OLD;
Andreas Gruenbacher
2005-Mar-29 13:54 UTC
[PATCH] kfree() NULL pointer cleanups - no need to check - fs/ext3/
On Friday 25 March 2005 23:11, Jesper Juhl wrote:> kfree() handles NULL pointers fine - checking is redundant.Looks good. Can you also fix that in fs/ext2/acl.c? Thanks, -- Andreas Gruenbacher <agruen at suse.de> SUSE Labs, SUSE LINUX PRODUCTS GMBH