[openib-general] [PATCH] ucm: Eliminate NULL checks prior to calling kfree

Hal Rosenstock halr at voltaire.com
Wed Jul 13 05:18:34 PDT 2005


ucm: Eliminate NULL checks prior to calling kfree

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: ucm.c
===================================================================
--- ucm.c	(revision 2838)
+++ ucm.c	(working copy)
@@ -378,10 +378,8 @@
 
 	return 0;
 error:
-	if (uvt->info)
-		kfree(uvt->info);
-	if (uvt->data)
-		kfree(uvt->data);
+	kfree(uvt->info);
+	kfree(uvt->data);
 	return result;
 }
 
@@ -551,10 +549,8 @@
 	list_del(&uevent->file_list);
 	list_del(&uevent->ctx_list);
 
-	if (uevent->data)
-		kfree(uevent->data);
-	if (uevent->info)
-		kfree(uevent->info);
+	kfree(uevent->data);
+	kfree(uevent->info);
 	kfree(uevent);
 done:
 	up(&file->mutex);
@@ -846,12 +842,9 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (param.private_data)
-		kfree(param.private_data);
-	if (param.primary_path)
-		kfree(param.primary_path);
-	if (param.alternate_path)
-		kfree(param.alternate_path);
+	kfree(param.private_data);
+	kfree(param.primary_path);
+	kfree(param.alternate_path);
 
 	return result;
 }
@@ -900,8 +893,7 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (param.private_data)
-		kfree(param.private_data);
+	kfree(param.private_data);
 
 	return result;
 }
@@ -939,8 +931,7 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (private_data)
-		kfree(private_data);
+	kfree(private_data);
 
 	return result;
 }
@@ -1009,10 +1000,8 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (data)
-		kfree(data);
-	if (info)
-		kfree(info);
+	kfree(data);
+	kfree(info);
 
 	return result;
 }
@@ -1063,8 +1052,7 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (data)
-		kfree(data);
+	kfree(data);
 
 	return result;
 }
@@ -1105,10 +1093,8 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (data)
-		kfree(data);
-	if (path)
-		kfree(path);
+	kfree(data);
+	kfree(path);
 
 	return result;
 }
@@ -1157,10 +1143,8 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (param.private_data)
-		kfree(param.private_data);
-	if (param.path)
-		kfree(param.path);
+	kfree(param.private_data);
+	kfree(param.path);
 
 	return result;
 }
@@ -1209,10 +1193,8 @@
 	up(&ctx->file->mutex);
 	ib_ucm_ctx_put(ctx); /* func reference */
 done:
-	if (param.private_data)
-		kfree(param.private_data);
-	if (param.info)
-		kfree(param.info);
+	kfree(param.private_data);
+	kfree(param.info);
 
 	return result;
 }






More information about the general mailing list