Commit 7713e5f5 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32a3fab2
...@@ -464,12 +464,9 @@ int lustre_start_mgc(struct super_block *sb) ...@@ -464,12 +464,9 @@ int lustre_start_mgc(struct super_block *sb)
out_free: out_free:
mutex_unlock(&mgc_start_lock); mutex_unlock(&mgc_start_lock);
if (data) kfree(data);
kfree(data); kfree(mgcname);
if (mgcname) kfree(niduuid);
kfree(mgcname);
if (niduuid)
kfree(niduuid);
return rc; return rc;
} }
...@@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb) ...@@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb)
niduuid, rc); niduuid, rc);
} }
out: out:
if (niduuid) kfree(niduuid);
kfree(niduuid);
/* class_import_put will get rid of the additional connections */ /* class_import_put will get rid of the additional connections */
mutex_unlock(&mgc_start_lock); mutex_unlock(&mgc_start_lock);
...@@ -585,22 +581,15 @@ static int lustre_free_lsi(struct super_block *sb) ...@@ -585,22 +581,15 @@ static int lustre_free_lsi(struct super_block *sb)
LASSERT(atomic_read(&lsi->lsi_mounts) == 0); LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
if (lsi->lsi_lmd != NULL) { if (lsi->lsi_lmd != NULL) {
if (lsi->lsi_lmd->lmd_dev != NULL) kfree(lsi->lsi_lmd->lmd_dev);
kfree(lsi->lsi_lmd->lmd_dev); kfree(lsi->lsi_lmd->lmd_profile);
if (lsi->lsi_lmd->lmd_profile != NULL) kfree(lsi->lsi_lmd->lmd_mgssec);
kfree(lsi->lsi_lmd->lmd_profile); kfree(lsi->lsi_lmd->lmd_opts);
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);
if (lsi->lsi_lmd->lmd_exclude_count) if (lsi->lsi_lmd->lmd_exclude_count)
kfree(lsi->lsi_lmd->lmd_exclude); kfree(lsi->lsi_lmd->lmd_exclude);
if (lsi->lsi_lmd->lmd_mgs != NULL) kfree(lsi->lsi_lmd->lmd_mgs);
kfree(lsi->lsi_lmd->lmd_mgs); kfree(lsi->lsi_lmd->lmd_osd_type);
if (lsi->lsi_lmd->lmd_osd_type != NULL) kfree(lsi->lsi_lmd->lmd_params);
kfree(lsi->lsi_lmd->lmd_osd_type);
if (lsi->lsi_lmd->lmd_params != NULL)
kfree(lsi->lsi_lmd->lmd_params);
kfree(lsi->lsi_lmd); kfree(lsi->lsi_lmd);
} }
...@@ -886,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) ...@@ -886,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
char *tail; char *tail;
int length; int length;
if (lmd->lmd_mgssec != NULL) { kfree(lmd->lmd_mgssec);
kfree(lmd->lmd_mgssec); lmd->lmd_mgssec = NULL;
lmd->lmd_mgssec = NULL;
}
tail = strchr(ptr, ','); tail = strchr(ptr, ',');
if (tail == NULL) if (tail == NULL)
...@@ -914,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr) ...@@ -914,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr)
if ((handle == NULL) || (ptr == NULL)) if ((handle == NULL) || (ptr == NULL))
return -EINVAL; return -EINVAL;
if (*handle != NULL) { kfree(*handle);
kfree(*handle); *handle = NULL;
*handle = NULL;
}
tail = strchr(ptr, ','); tail = strchr(ptr, ',');
if (tail == NULL) if (tail == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment