Fix dsl_prop_get_all_dsl() memory leak

On error dsl_prop_get_all_ds() does not free the nvlist it allocates.
This behavior may have been intentional when originally written
but is atypical and often confusing.  Since no callers rely on this
behavior the function has been updated to always free the nvlist
on error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: BearBabyLiu <liu.huang@zte.com.cn>
Closes #5320
This commit is contained in:
BearBabyLiu 2016-11-03 03:34:10 +08:00 committed by Brian Behlendorf
parent e676a19624
commit 6d4210052b
2 changed files with 7 additions and 1 deletions

View File

@ -1127,6 +1127,10 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
break;
}
out:
if (err) {
nvlist_free(*nvp);
*nvp = NULL;
}
return (err);
}

View File

@ -2033,8 +2033,10 @@ zfs_ioc_objset_stats_impl(zfs_cmd_t *zc, objset_t *os)
if (!zc->zc_objset_stats.dds_inconsistent &&
dmu_objset_type(os) == DMU_OST_ZVOL) {
error = zvol_get_stats(os, nv);
if (error == EIO)
if (error == EIO) {
nvlist_free(nv);
return (error);
}
VERIFY0(error);
}
if (error == 0)