staging: lustre: obdclass: genops: remove unneeded null test before free

Author: Julia Lawall <Julia.Lawall@lip6.fr>

Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// 

Signed-off-by: Julia Lawall 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/lustre/lustre/obdclass/genops.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
 
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index a107aea..37d6aef 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -213,12 +213,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	return 0;
 
  failed:
-	if (type->typ_name != NULL)
-		kfree(type->typ_name);
-	if (type->typ_md_ops != NULL)
-		kfree(type->typ_md_ops);
-	if (type->typ_dt_ops != NULL)
-		kfree(type->typ_dt_ops);
+	kfree(type->typ_name);
+	kfree(type->typ_md_ops);
+	kfree(type->typ_dt_ops);
 	kfree(type);
 	return rc;
 }
@@ -253,10 +250,8 @@ int class_unregister_type(const char *name)
 	list_del(&type->typ_chain);
 	spin_unlock(&obd_types_lock);
 	kfree(type->typ_name);
-	if (type->typ_dt_ops != NULL)
-		kfree(type->typ_dt_ops);
-	if (type->typ_md_ops != NULL)
-		kfree(type->typ_md_ops);
+	kfree(type->typ_dt_ops);
+	kfree(type->typ_md_ops);
 	kfree(type);
 	return 0;
 } /* class_unregister_type */
BtrLinux
Résumé de la politique de confidentialité

Ce site utilise des cookies afin que nous puissions vous fournir la meilleure expérience utilisateur possible. Les informations sur les cookies sont stockées dans votre navigateur et remplissent des fonctions telles que vous reconnaître lorsque vous revenez sur notre site Web et aider notre équipe à comprendre les sections du site que vous trouvez les plus intéressantes et utiles.