lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430509086-22132-7-git-send-email-Julia.Lawall@lip6.fr>
Date:	Fri,  1 May 2015 21:37:52 +0200
From:	Julia Lawall <Julia.Lawall@...6.fr>
To:	Oleg Drokin <oleg.drokin@...el.com>
Cc:	kernel-janitors@...r.kernel.org,
	Andreas Dilger <andreas.dilger@...el.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	HPDD-discuss@...ts.01.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 15/20] staging: lustre: obdclass: obd_mount: remove unneeded null test before free

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/)

// <smpl>
@@ expression ptr; @@

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

@@ expression ptr; @@

- if (ptr != NULL) {
  kfree(ptr);
  ptr = NULL;
- }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@...6.fr>

---
 drivers/staging/lustre/lustre/obdclass/obd_mount.c |   45 +++++++--------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 04a22169..1f9a5f7 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -464,12 +464,9 @@ out:
 out_free:
 	mutex_unlock(&mgc_start_lock);
 
-	if (data)
-		kfree(data);
-	if (mgcname)
-		kfree(mgcname);
-	if (niduuid)
-		kfree(niduuid);
+	kfree(data);
+	kfree(mgcname);
+	kfree(niduuid);
 	return rc;
 }
 
@@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb)
 			       niduuid, rc);
 	}
 out:
-	if (niduuid)
-		kfree(niduuid);
+	kfree(niduuid);
 
 	/* class_import_put will get rid of the additional connections */
 	mutex_unlock(&mgc_start_lock);
@@ -585,22 +581,15 @@ static int lustre_free_lsi(struct super_block *sb)
 	LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
 
 	if (lsi->lsi_lmd != NULL) {
-		if (lsi->lsi_lmd->lmd_dev != NULL)
-			kfree(lsi->lsi_lmd->lmd_dev);
-		if (lsi->lsi_lmd->lmd_profile != NULL)
-			kfree(lsi->lsi_lmd->lmd_profile);
-		if (lsi->lsi_lmd->lmd_mgssec != NULL)
-			kfree(lsi->lsi_lmd->lmd_mgssec);
-		if (lsi->lsi_lmd->lmd_opts != NULL)
-			kfree(lsi->lsi_lmd->lmd_opts);
+		kfree(lsi->lsi_lmd->lmd_dev);
+		kfree(lsi->lsi_lmd->lmd_profile);
+		kfree(lsi->lsi_lmd->lmd_mgssec);
+		kfree(lsi->lsi_lmd->lmd_opts);
 		if (lsi->lsi_lmd->lmd_exclude_count)
 			kfree(lsi->lsi_lmd->lmd_exclude);
-		if (lsi->lsi_lmd->lmd_mgs != NULL)
-			kfree(lsi->lsi_lmd->lmd_mgs);
-		if (lsi->lsi_lmd->lmd_osd_type != NULL)
-			kfree(lsi->lsi_lmd->lmd_osd_type);
-		if (lsi->lsi_lmd->lmd_params != NULL)
-			kfree(lsi->lsi_lmd->lmd_params);
+		kfree(lsi->lsi_lmd->lmd_mgs);
+		kfree(lsi->lsi_lmd->lmd_osd_type);
+		kfree(lsi->lsi_lmd->lmd_params);
 
 		kfree(lsi->lsi_lmd);
 	}
@@ -886,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
 	char   *tail;
 	int     length;
 
-	if (lmd->lmd_mgssec != NULL) {
-		kfree(lmd->lmd_mgssec);
-		lmd->lmd_mgssec = NULL;
-	}
+	kfree(lmd->lmd_mgssec);
+	lmd->lmd_mgssec = NULL;
 
 	tail = strchr(ptr, ',');
 	if (tail == NULL)
@@ -914,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr)
 	if ((handle == NULL) || (ptr == NULL))
 		return -EINVAL;
 
-	if (*handle != NULL) {
-		kfree(*handle);
-		*handle = NULL;
-	}
+	kfree(*handle);
+	*handle = NULL;
 
 	tail = strchr(ptr, ',');
 	if (tail == NULL)

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ