[PATCH] remove null pointer checks prior to calling kfree() - in fs/nfs/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(please keep me on CC)


kfree() has no problem dealing with NULL pointers.


Signed-off-by: Jesper Juhl <[email protected]>

--- linux-2.6.12-rc1-mm3-orig/fs/nfs/delegation.c	2005-03-25 15:28:59.000000000 +0100
+++ linux-2.6.12-rc1-mm3/fs/nfs/delegation.c	2005-03-25 21:43:29.000000000 +0100
@@ -111,8 +111,7 @@ int nfs_inode_set_delegation(struct inod
 		}
 	}
 	spin_unlock(&clp->cl_lock);
-	if (delegation != NULL)
-		kfree(delegation);
+	kfree(delegation);
 	return status;
 }
 
--- linux-2.6.12-rc1-mm3-orig/fs/nfs/inode.c	2005-03-25 15:28:59.000000000 +0100
+++ linux-2.6.12-rc1-mm3/fs/nfs/inode.c	2005-03-25 21:44:28.000000000 +0100
@@ -1553,8 +1553,7 @@ static void nfs_kill_super(struct super_
 
 	rpciod_down();		/* release rpciod */
 
-	if (server->hostname != NULL)
-		kfree(server->hostname);
+	kfree(server->hostname);
 	kfree(server);
 }
 
@@ -1796,8 +1795,7 @@ nfs_copy_user_string(char *dst, struct n
 			return ERR_PTR(-ENOMEM);
 	}
 	if (copy_from_user(dst, src->data, maxlen)) {
-		if (p != NULL)
-			kfree(p);
+		kfree(p);
 		return ERR_PTR(-EFAULT);
 	}
 	dst[maxlen] = '\0';
@@ -1887,10 +1885,8 @@ static struct super_block *nfs4_get_sb(s
 out_err:
 	s = (struct super_block *)p;
 out_free:
-	if (server->mnt_path)
-		kfree(server->mnt_path);
-	if (server->hostname)
-		kfree(server->hostname);
+	kfree(server->mnt_path);
+	kfree(server->hostname);
 	kfree(server);
 	return s;
 }
@@ -1910,8 +1906,7 @@ static void nfs4_kill_super(struct super
 
 	destroy_nfsv4_state(server);
 
-	if (server->hostname != NULL)
-		kfree(server->hostname);
+	kfree(server->hostname);
 	kfree(server);
 }
 
--- linux-2.6.12-rc1-mm3-orig/fs/nfs/nfs4state.c	2005-03-25 15:28:59.000000000 +0100
+++ linux-2.6.12-rc1-mm3/fs/nfs/nfs4state.c	2005-03-25 21:45:47.000000000 +0100
@@ -69,10 +69,9 @@ init_nfsv4_state(struct nfs_server *serv
 void
 destroy_nfsv4_state(struct nfs_server *server)
 {
-	if (server->mnt_path) {
-		kfree(server->mnt_path);
-		server->mnt_path = NULL;
-	}
+	kfree(server->mnt_path);
+	server->mnt_path = NULL;
+
 	if (server->nfs4_state) {
 		nfs4_put_client(server->nfs4_state);
 		server->nfs4_state = NULL;
@@ -307,8 +306,7 @@ struct nfs4_state_owner *nfs4_get_state_
 		new = NULL;
 	}
 	spin_unlock(&clp->cl_lock);
-	if (new)
-		kfree(new);
+	kfree(new);
 	if (sp != NULL)
 		return sp;
 	put_rpccred(cred);
--- linux-2.6.12-rc1-mm3-orig/fs/nfs/proc.c	2005-03-25 15:28:59.000000000 +0100
+++ linux-2.6.12-rc1-mm3/fs/nfs/proc.c	2005-03-25 21:46:22.000000000 +0100
@@ -329,8 +329,7 @@ nfs_proc_unlink_done(struct dentry *dir,
 {
 	struct rpc_message *msg = &task->tk_msg;
 	
-	if (msg->rpc_argp)
-		kfree(msg->rpc_argp);
+	kfree(msg->rpc_argp);
 	return 0;
 }
 
--- linux-2.6.12-rc1-mm3-orig/fs/nfs/unlink.c	2005-03-21 23:12:41.000000000 +0100
+++ linux-2.6.12-rc1-mm3/fs/nfs/unlink.c	2005-03-25 21:46:41.000000000 +0100
@@ -52,8 +52,7 @@ nfs_put_unlinkdata(struct nfs_unlinkdata
 {
 	if (--data->count == 0) {
 		nfs_detach_unlinkdata(data);
-		if (data->name.name != NULL)
-			kfree(data->name.name);
+		kfree(data->name.name);
 		kfree(data);
 	}
 }


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux