Illumos 6659 - nvlist_free(NULL) is a no-op

6659 nvlist_free(NULL) is a no-op
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Marcel Telka <marcel@telka.sk>
Approved by: Robert Mustacchi <rm@joyent.com>

References:
  https://www.illumos.org/issues/6659
  https://github.com/illumos/illumos-gate/commit/aab83bb

Ported-by: David Quigley <dpquigl@davequigley.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4566
This commit is contained in:
Josef 'Jeff' Sipek 2016-03-31 23:54:07 -04:00 committed by Brian Behlendorf
parent 16794374b3
commit 8a5fc74880
11 changed files with 19 additions and 39 deletions

View File

@ -5294,8 +5294,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
cleanup0: cleanup0:
nvlist_free(perm_nvl); nvlist_free(perm_nvl);
if (update_perm_nvl != NULL) nvlist_free(update_perm_nvl);
nvlist_free(update_perm_nvl);
cleanup1: cleanup1:
fs_perm_set_fini(&fs_perm_set); fs_perm_set_fini(&fs_perm_set);
cleanup2: cleanup2:

View File

@ -3674,8 +3674,7 @@ zpool_do_split(int argc, char **argv)
if (add_prop_list( if (add_prop_list(
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), optarg, zpool_prop_to_name(ZPOOL_PROP_ALTROOT), optarg,
&props, B_TRUE) != 0) { &props, B_TRUE) != 0) {
if (props) nvlist_free(props);
nvlist_free(props);
usage(B_FALSE); usage(B_FALSE);
} }
break; break;
@ -3688,8 +3687,7 @@ zpool_do_split(int argc, char **argv)
propval++; propval++;
if (add_prop_list(optarg, propval, if (add_prop_list(optarg, propval,
&props, B_TRUE) != 0) { &props, B_TRUE) != 0) {
if (props) nvlist_free(props);
nvlist_free(props);
usage(B_FALSE); usage(B_FALSE);
} }
} else { } else {

View File

@ -1675,8 +1675,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props,
} }
if (zpool_vdev_split(zhp, newname, &newroot, props, flags) != 0) { if (zpool_vdev_split(zhp, newname, &newroot, props, flags) != 0) {
if (newroot != NULL) nvlist_free(newroot);
nvlist_free(newroot);
return (NULL); return (NULL);
} }

View File

@ -311,8 +311,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
zhp->zpool_config_size = zc.zc_nvlist_dst_size; zhp->zpool_config_size = zc.zc_nvlist_dst_size;
if (zhp->zpool_config != NULL) { if (zhp->zpool_config != NULL) {
if (zhp->zpool_old_config != NULL) nvlist_free(zhp->zpool_old_config);
nvlist_free(zhp->zpool_old_config);
zhp->zpool_old_config = zhp->zpool_config; zhp->zpool_old_config = zhp->zpool_config;
} }

View File

@ -2079,8 +2079,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
zcmd_free_nvlists(&zc); zcmd_free_nvlists(&zc);
return (-1); return (-1);
} }
if (zplprops) nvlist_free(zplprops);
nvlist_free(zplprops);
zcmd_free_nvlists(&zc); zcmd_free_nvlists(&zc);
break; break;
@ -4269,8 +4268,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
return (-1); return (-1);
} }
error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc); error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc);
if (nvlist) nvlist_free(nvlist);
nvlist_free(nvlist);
return (error); return (error);
} }

View File

@ -1973,8 +1973,7 @@ error:
venext = ve->ve_next; venext = ve->ve_next;
for (ce = ve->ve_configs; ce != NULL; ce = cenext) { for (ce = ve->ve_configs; ce != NULL; ce = cenext) {
cenext = ce->ce_next; cenext = ce->ce_next;
if (ce->ce_config) nvlist_free(ce->ce_config);
nvlist_free(ce->ce_config);
free(ce); free(ce);
} }
free(ve); free(ve);

View File

@ -1146,12 +1146,9 @@ zpool_open(libzfs_handle_t *hdl, const char *pool)
void void
zpool_close(zpool_handle_t *zhp) zpool_close(zpool_handle_t *zhp)
{ {
if (zhp->zpool_config) nvlist_free(zhp->zpool_config);
nvlist_free(zhp->zpool_config); nvlist_free(zhp->zpool_old_config);
if (zhp->zpool_old_config) nvlist_free(zhp->zpool_props);
nvlist_free(zhp->zpool_old_config);
if (zhp->zpool_props)
nvlist_free(zhp->zpool_props);
free(zhp); free(zhp);
} }
@ -1688,8 +1685,7 @@ zpool_import(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
ret = zpool_import_props(hdl, config, newname, props, ret = zpool_import_props(hdl, config, newname, props,
ZFS_IMPORT_NORMAL); ZFS_IMPORT_NORMAL);
if (props) nvlist_free(props);
nvlist_free(props);
return (ret); return (ret);
} }
@ -2959,8 +2955,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
&children) != 0) { &children) != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"Source pool is missing vdev tree")); "Source pool is missing vdev tree"));
if (zc_props) nvlist_free(zc_props);
nvlist_free(zc_props);
return (-1); return (-1);
} }
@ -3108,10 +3103,8 @@ out:
free(varray); free(varray);
} }
zcmd_free_nvlists(&zc); zcmd_free_nvlists(&zc);
if (zc_props) nvlist_free(zc_props);
nvlist_free(zc_props); nvlist_free(newconfig);
if (newconfig)
nvlist_free(newconfig);
if (freelist) { if (freelist) {
nvlist_free(*newroot); nvlist_free(*newroot);
*newroot = NULL; *newroot = NULL;

View File

@ -2545,8 +2545,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
out: out:
fsavl_destroy(stream_avl); fsavl_destroy(stream_avl);
if (stream_nv) nvlist_free(stream_nv);
nvlist_free(stream_nv);
if (softerr) if (softerr)
error = -2; error = -2;
if (anyerr) if (anyerr)

View File

@ -6132,8 +6132,7 @@ spa_sync_config_object(spa_t *spa, dmu_tx_t *tx)
spa_config_exit(spa, SCL_STATE, FTAG); spa_config_exit(spa, SCL_STATE, FTAG);
if (spa->spa_config_syncing) nvlist_free(spa->spa_config_syncing);
nvlist_free(spa->spa_config_syncing);
spa->spa_config_syncing = config; spa->spa_config_syncing = config;
spa_sync_nvlist(spa, spa->spa_config_object, config, tx); spa_sync_nvlist(spa, spa->spa_config_object, config, tx);

View File

@ -376,8 +376,7 @@ void
spa_config_set(spa_t *spa, nvlist_t *config) spa_config_set(spa_t *spa, nvlist_t *config)
{ {
mutex_enter(&spa->spa_props_lock); mutex_enter(&spa->spa_props_lock);
if (spa->spa_config != NULL) nvlist_free(spa->spa_config);
nvlist_free(spa->spa_config);
spa->spa_config = config; spa->spa_config = config;
mutex_exit(&spa->spa_props_lock); mutex_exit(&spa->spa_props_lock);
} }

View File

@ -1536,9 +1536,7 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
} }
nvlist_free(config); nvlist_free(config);
nvlist_free(props);
if (props)
nvlist_free(props);
return (error); return (error);
} }