[PATCH] kfree() NULL pointer cleanups - no need to check - fs/ext3/

Jesper Juhl juhl-lkml at dif.dk
Fri Mar 25 22:11:45 UTC 2005


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;






More information about the Ext3-users mailing list