Fix strdup conflict on other platforms

In the FreeBSD kernel the strdup signature is:

```
char	*strdup(const char *__restrict, struct malloc_type *);
```

It's unfortunate that the developers have chosen to change
the signature of libc functions - but it's what I have to
deal with.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9433
This commit is contained in:
Matthew Macy 2019-10-10 09:47:06 -07:00 committed by Brian Behlendorf
parent c5858ff946
commit e4f5fa1229
21 changed files with 76 additions and 75 deletions

View File

@ -2863,7 +2863,7 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id)
zpool_prop_to_name(ZPOOL_PROP_VERSION))); zpool_prop_to_name(ZPOOL_PROP_VERSION)));
spa_close(spa, FTAG); spa_close(spa, FTAG);
strfree(name); kmem_strfree(name);
mutex_exit(&ztest_vdev_lock); mutex_exit(&ztest_vdev_lock);
} }

View File

@ -32,8 +32,8 @@
extern int kmem_debugging(void); extern int kmem_debugging(void);
extern char *kmem_vasprintf(const char *fmt, va_list ap); extern char *kmem_vasprintf(const char *fmt, va_list ap);
extern char *kmem_asprintf(const char *fmt, ...); extern char *kmem_asprintf(const char *fmt, ...);
extern char *strdup(const char *str); extern char *kmem_strdup(const char *str);
extern void strfree(char *str); extern void kmem_strfree(char *str);
/* /*
* Memory allocation interfaces * Memory allocation interfaces

View File

@ -722,7 +722,8 @@ extern uint32_t zone_get_hostid(void *zonep);
extern char *kmem_vasprintf(const char *fmt, va_list adx); extern char *kmem_vasprintf(const char *fmt, va_list adx);
extern char *kmem_asprintf(const char *fmt, ...); extern char *kmem_asprintf(const char *fmt, ...);
#define strfree(str) kmem_free((str), strlen(str) + 1) #define kmem_strfree(str) kmem_free((str), strlen(str) + 1)
#define kmem_strdup(s) strdup(s)
/* /*
* Hostname information * Hostname information

View File

@ -261,7 +261,7 @@ crypto_register_provider(crypto_provider_info_t *info,
prov_desc->pd_kstat->ks_update = kcf_prov_kstat_update; prov_desc->pd_kstat->ks_update = kcf_prov_kstat_update;
kstat_install(prov_desc->pd_kstat); kstat_install(prov_desc->pd_kstat);
} }
strfree(ks_name); kmem_strfree(ks_name);
} }
if (prov_desc->pd_prov_type == CRYPTO_HW_PROVIDER) if (prov_desc->pd_prov_type == CRYPTO_HW_PROVIDER)

View File

@ -120,18 +120,18 @@ __strdup(const char *str, int flags)
} }
char * char *
strdup(const char *str) kmem_strdup(const char *str)
{ {
return (__strdup(str, KM_SLEEP)); return (__strdup(str, KM_SLEEP));
} }
EXPORT_SYMBOL(strdup); EXPORT_SYMBOL(kmem_strdup);
void void
strfree(char *str) kmem_strfree(char *str)
{ {
kfree(str); kfree(str);
} }
EXPORT_SYMBOL(strfree); EXPORT_SYMBOL(kmem_strfree);
/* /*
* General purpose unified implementation of kmem_alloc(). It is an * General purpose unified implementation of kmem_alloc(). It is an

View File

@ -631,7 +631,7 @@ kstat_detect_collision(kstat_proc_entry_t *kpep)
parent = kmem_asprintf("%s", kpep->kpe_module); parent = kmem_asprintf("%s", kpep->kpe_module);
if ((cp = strrchr(parent, '/')) == NULL) { if ((cp = strrchr(parent, '/')) == NULL) {
strfree(parent); kmem_strfree(parent);
return (0); return (0);
} }
@ -639,13 +639,13 @@ kstat_detect_collision(kstat_proc_entry_t *kpep)
if ((module = kstat_find_module(parent)) != NULL) { if ((module = kstat_find_module(parent)) != NULL) {
list_for_each_entry(tmp, &module->ksm_kstat_list, kpe_list) { list_for_each_entry(tmp, &module->ksm_kstat_list, kpe_list) {
if (strncmp(tmp->kpe_name, cp+1, KSTAT_STRLEN) == 0) { if (strncmp(tmp->kpe_name, cp+1, KSTAT_STRLEN) == 0) {
strfree(parent); kmem_strfree(parent);
return (EEXIST); return (EEXIST);
} }
} }
} }
strfree(parent); kmem_strfree(parent);
return (0); return (0);
} }

View File

@ -1038,7 +1038,7 @@ taskq_create(const char *name, int nthreads, pri_t pri,
spin_lock_init(&tq->tq_lock); spin_lock_init(&tq->tq_lock);
INIT_LIST_HEAD(&tq->tq_thread_list); INIT_LIST_HEAD(&tq->tq_thread_list);
INIT_LIST_HEAD(&tq->tq_active_list); INIT_LIST_HEAD(&tq->tq_active_list);
tq->tq_name = strdup(name); tq->tq_name = kmem_strdup(name);
tq->tq_nactive = 0; tq->tq_nactive = 0;
tq->tq_nthreads = 0; tq->tq_nthreads = 0;
tq->tq_nspawn = 0; tq->tq_nspawn = 0;
@ -1178,7 +1178,7 @@ taskq_destroy(taskq_t *tq)
spin_unlock_irqrestore(&tq->tq_lock, flags); spin_unlock_irqrestore(&tq->tq_lock, flags);
strfree(tq->tq_name); kmem_strfree(tq->tq_name);
kmem_free(tq, sizeof (taskq_t)); kmem_free(tq, sizeof (taskq_t));
} }
EXPORT_SYMBOL(taskq_destroy); EXPORT_SYMBOL(taskq_destroy);

View File

@ -138,7 +138,7 @@ spa_read_history_init(spa_t *spa)
spa_read_history_clear, spa_read_history_clear,
offsetof(spa_read_history_t, srh_node)); offsetof(spa_read_history_t, srh_node));
strfree(module); kmem_strfree(module);
} }
static void static void
@ -309,7 +309,7 @@ spa_txg_history_init(spa_t *spa)
spa_txg_history_clear, spa_txg_history_clear,
offsetof(spa_txg_history_t, sth_node)); offsetof(spa_txg_history_t, sth_node));
strfree(module); kmem_strfree(module);
} }
static void static void
@ -529,7 +529,7 @@ spa_tx_assign_init(spa_t *spa)
ksp->ks_update = spa_tx_assign_update; ksp->ks_update = spa_tx_assign_update;
kstat_install(ksp); kstat_install(ksp);
} }
strfree(name); kmem_strfree(name);
} }
static void static void
@ -592,7 +592,7 @@ spa_io_history_init(spa_t *spa)
ksp->ks_update = spa_io_history_update; ksp->ks_update = spa_io_history_update;
kstat_install(ksp); kstat_install(ksp);
} }
strfree(name); kmem_strfree(name);
} }
static void static void
@ -675,7 +675,7 @@ spa_mmp_history_truncate(spa_history_list_t *shl, unsigned int size)
while (shl->size > size) { while (shl->size > size) {
smh = list_remove_head(&shl->procfs_list.pl_list); smh = list_remove_head(&shl->procfs_list.pl_list);
if (smh->vdev_path) if (smh->vdev_path)
strfree(smh->vdev_path); kmem_strfree(smh->vdev_path);
kmem_free(smh, sizeof (spa_mmp_history_t)); kmem_free(smh, sizeof (spa_mmp_history_t));
shl->size--; shl->size--;
} }
@ -715,7 +715,7 @@ spa_mmp_history_init(spa_t *spa)
spa_mmp_history_clear, spa_mmp_history_clear,
offsetof(spa_mmp_history_t, smh_node)); offsetof(spa_mmp_history_t, smh_node));
strfree(module); kmem_strfree(module);
} }
static void static void
@ -814,7 +814,7 @@ spa_mmp_history_add(spa_t *spa, uint64_t txg, uint64_t timestamp,
if (vd) { if (vd) {
smh->vdev_guid = vd->vdev_guid; smh->vdev_guid = vd->vdev_guid;
if (vd->vdev_path) if (vd->vdev_path)
smh->vdev_path = strdup(vd->vdev_path); smh->vdev_path = kmem_strdup(vd->vdev_path);
} }
smh->vdev_label = label; smh->vdev_label = label;
smh->mmp_node_id = mmp_node_id; smh->mmp_node_id = mmp_node_id;
@ -876,7 +876,7 @@ spa_state_init(spa_t *spa)
kstat_install(ksp); kstat_install(ksp);
} }
strfree(name); kmem_strfree(name);
} }
static void static void
@ -973,7 +973,7 @@ spa_iostats_init(spa_t *spa)
kstat_install(ksp); kstat_install(ksp);
} }
strfree(name); kmem_strfree(name);
} }
static void static void

View File

@ -220,7 +220,7 @@ vdev_elevator_switch(vdev_t *v, char *elevator)
argv[2] = kmem_asprintf(SET_SCHEDULER_CMD, device, elevator); argv[2] = kmem_asprintf(SET_SCHEDULER_CMD, device, elevator);
error = call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT); error = call_usermodehelper(argv[0], argv, envp, UMH_NO_WAIT);
strfree(argv[2]); kmem_strfree(argv[2]);
#endif /* HAVE_ELEVATOR_CHANGE */ #endif /* HAVE_ELEVATOR_CHANGE */
if (error) { if (error) {
zfs_dbgmsg("Unable to set \"%s\" scheduler for %s (%s): %d", zfs_dbgmsg("Unable to set \"%s\" scheduler for %s (%s): %d",

View File

@ -137,8 +137,8 @@ zfsctl_snapshot_alloc(char *full_name, char *full_path, spa_t *spa,
se = kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP); se = kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP);
se->se_name = strdup(full_name); se->se_name = kmem_strdup(full_name);
se->se_path = strdup(full_path); se->se_path = kmem_strdup(full_path);
se->se_spa = spa; se->se_spa = spa;
se->se_objsetid = objsetid; se->se_objsetid = objsetid;
se->se_root_dentry = root_dentry; se->se_root_dentry = root_dentry;
@ -157,8 +157,8 @@ static void
zfsctl_snapshot_free(zfs_snapentry_t *se) zfsctl_snapshot_free(zfs_snapentry_t *se)
{ {
zfs_refcount_destroy(&se->se_refcount); zfs_refcount_destroy(&se->se_refcount);
strfree(se->se_name); kmem_strfree(se->se_name);
strfree(se->se_path); kmem_strfree(se->se_path);
kmem_free(se, sizeof (zfs_snapentry_t)); kmem_free(se, sizeof (zfs_snapentry_t));
} }
@ -311,8 +311,8 @@ zfsctl_snapshot_rename(char *old_snapname, char *new_snapname)
return (SET_ERROR(ENOENT)); return (SET_ERROR(ENOENT));
zfsctl_snapshot_remove(se); zfsctl_snapshot_remove(se);
strfree(se->se_name); kmem_strfree(se->se_name);
se->se_name = strdup(new_snapname); se->se_name = kmem_strdup(new_snapname);
zfsctl_snapshot_add(se); zfsctl_snapshot_add(se);
zfsctl_snapshot_rele(se); zfsctl_snapshot_rele(se);

View File

@ -111,7 +111,7 @@ zfsvfs_vfs_free(vfs_t *vfsp)
{ {
if (vfsp != NULL) { if (vfsp != NULL) {
if (vfsp->vfs_mntpoint != NULL) if (vfsp->vfs_mntpoint != NULL)
strfree(vfsp->vfs_mntpoint); kmem_strfree(vfsp->vfs_mntpoint);
kmem_free(vfsp, sizeof (vfs_t)); kmem_free(vfsp, sizeof (vfs_t));
} }
@ -222,7 +222,7 @@ zfsvfs_parse_options(char *mntopts, vfs_t **vfsp)
char *tmp_mntopts, *p, *t; char *tmp_mntopts, *p, *t;
int token; int token;
tmp_mntopts = t = strdup(mntopts); tmp_mntopts = t = kmem_strdup(mntopts);
if (tmp_mntopts == NULL) if (tmp_mntopts == NULL)
return (SET_ERROR(ENOMEM)); return (SET_ERROR(ENOMEM));
@ -234,13 +234,13 @@ zfsvfs_parse_options(char *mntopts, vfs_t **vfsp)
token = match_token(p, zpl_tokens, args); token = match_token(p, zpl_tokens, args);
error = zfsvfs_parse_option(p, token, args, tmp_vfsp); error = zfsvfs_parse_option(p, token, args, tmp_vfsp);
if (error) { if (error) {
strfree(tmp_mntopts); kmem_strfree(tmp_mntopts);
zfsvfs_vfs_free(tmp_vfsp); zfsvfs_vfs_free(tmp_vfsp);
return (error); return (error);
} }
} }
strfree(tmp_mntopts); kmem_strfree(tmp_mntopts);
} }
*vfsp = tmp_vfsp; *vfsp = tmp_vfsp;

View File

@ -707,7 +707,7 @@ __zpl_xattr_user_get(struct inode *ip, const char *name,
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size); error = zpl_xattr_get(ip, xattr_name, value, size);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }
@ -729,7 +729,7 @@ __zpl_xattr_user_set(struct inode *ip, const char *name,
xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags); error = zpl_xattr_set(ip, xattr_name, value, size, flags);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }
@ -776,7 +776,7 @@ __zpl_xattr_trusted_get(struct inode *ip, const char *name,
#endif #endif
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size); error = zpl_xattr_get(ip, xattr_name, value, size);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }
@ -798,7 +798,7 @@ __zpl_xattr_trusted_set(struct inode *ip, const char *name,
#endif #endif
xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_TRUSTED_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags); error = zpl_xattr_set(ip, xattr_name, value, size, flags);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }
@ -845,7 +845,7 @@ __zpl_xattr_security_get(struct inode *ip, const char *name,
#endif #endif
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_get(ip, xattr_name, value, size); error = zpl_xattr_get(ip, xattr_name, value, size);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }
@ -864,7 +864,7 @@ __zpl_xattr_security_set(struct inode *ip, const char *name,
#endif #endif
xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name); xattr_name = kmem_asprintf("%s%s", XATTR_SECURITY_PREFIX, name);
error = zpl_xattr_set(ip, xattr_name, value, size, flags); error = zpl_xattr_set(ip, xattr_name, value, size, flags);
strfree(xattr_name); kmem_strfree(xattr_name);
return (error); return (error);
} }

View File

@ -1404,7 +1404,7 @@ dmu_objset_snapshot_one(const char *fsname, const char *snapname)
nvlist_t *snaps = fnvlist_alloc(); nvlist_t *snaps = fnvlist_alloc();
fnvlist_add_boolean(snaps, longsnap); fnvlist_add_boolean(snaps, longsnap);
strfree(longsnap); kmem_strfree(longsnap);
err = dsl_dataset_snapshot(snaps, NULL, NULL); err = dsl_dataset_snapshot(snaps, NULL, NULL);
fnvlist_free(snaps); fnvlist_free(snaps);
return (err); return (err);
@ -2795,7 +2795,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
err = dmu_objset_find_impl(spa, child, err = dmu_objset_find_impl(spa, child,
func, arg, flags); func, arg, flags);
dsl_pool_config_enter(dp, FTAG); dsl_pool_config_enter(dp, FTAG);
strfree(child); kmem_strfree(child);
if (err != 0) if (err != 0)
break; break;
} }
@ -2833,7 +2833,7 @@ dmu_objset_find_impl(spa_t *spa, const char *name,
dsl_pool_config_exit(dp, FTAG); dsl_pool_config_exit(dp, FTAG);
err = func(child, arg); err = func(child, arg);
dsl_pool_config_enter(dp, FTAG); dsl_pool_config_enter(dp, FTAG);
strfree(child); kmem_strfree(child);
if (err != 0) if (err != 0)
break; break;
} }

View File

@ -2435,7 +2435,7 @@ get_receive_resume_stats_impl(dsl_dataset_t *ds)
kmem_free(compressed, packed_size); kmem_free(compressed, packed_size);
return (propval); return (propval);
} }
return (strdup("")); return (kmem_strdup(""));
} }
/* /*
@ -2458,7 +2458,7 @@ get_child_receive_stats(dsl_dataset_t *ds)
dsl_dataset_rele(recv_ds, FTAG); dsl_dataset_rele(recv_ds, FTAG);
return (propval); return (propval);
} }
return (strdup("")); return (kmem_strdup(""));
} }
static void static void
@ -2474,9 +2474,9 @@ get_receive_resume_stats(dsl_dataset_t *ds, nvlist_t *nv)
dsl_prop_nvlist_add_string(nv, dsl_prop_nvlist_add_string(nv,
ZFS_PROP_RECEIVE_RESUME_TOKEN, childval); ZFS_PROP_RECEIVE_RESUME_TOKEN, childval);
} }
strfree(childval); kmem_strfree(childval);
} }
strfree(propval); kmem_strfree(propval);
} }
uint64_t uint64_t

View File

@ -1200,7 +1200,7 @@ dsl_pool_user_hold_rele_impl(dsl_pool_t *dp, uint64_t dsobj,
error = zap_add(mos, zapobj, name, 8, 1, &now, tx); error = zap_add(mos, zapobj, name, 8, 1, &now, tx);
else else
error = zap_remove(mos, zapobj, name, tx); error = zap_remove(mos, zapobj, name, tx);
strfree(name); kmem_strfree(name);
return (error); return (error);
} }

View File

@ -150,8 +150,8 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
if (err == ENOENT) if (err == ENOENT)
err = dodefault(prop, intsz, numints, buf); err = dodefault(prop, intsz, numints, buf);
strfree(inheritstr); kmem_strfree(inheritstr);
strfree(recvdstr); kmem_strfree(recvdstr);
return (err); return (err);
} }
@ -190,7 +190,7 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname,
char *inheritstr = kmem_asprintf("%s%s", propname, char *inheritstr = kmem_asprintf("%s%s", propname,
ZPROP_INHERIT_SUFFIX); ZPROP_INHERIT_SUFFIX);
err = zap_contains(mos, zapobj, inheritstr); err = zap_contains(mos, zapobj, inheritstr);
strfree(inheritstr); kmem_strfree(inheritstr);
if (err != 0 && err != ENOENT) if (err != 0 && err != ENOENT)
return (err); return (err);
} }
@ -201,7 +201,7 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname,
ZPROP_RECVD_SUFFIX); ZPROP_RECVD_SUFFIX);
err = zap_lookup(mos, zapobj, recvdstr, err = zap_lookup(mos, zapobj, recvdstr,
intsz, numints, buf); intsz, numints, buf);
strfree(recvdstr); kmem_strfree(recvdstr);
if (err != ENOENT) { if (err != ENOENT) {
if (setpoint != NULL && err == 0) if (setpoint != NULL && err == 0)
(void) strcpy(setpoint, (void) strcpy(setpoint,
@ -424,7 +424,7 @@ dsl_prop_predict(dsl_dir_t *dd, const char *propname,
panic("unexpected property source: %d", source); panic("unexpected property source: %d", source);
} }
strfree(recvdstr); kmem_strfree(recvdstr);
if (err == ENOENT) if (err == ENOENT)
return (0); return (0);
@ -752,8 +752,8 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname,
cmn_err(CE_PANIC, "unexpected property source: %d", source); cmn_err(CE_PANIC, "unexpected property source: %d", source);
} }
strfree(inheritstr); kmem_strfree(inheritstr);
strfree(recvdstr); kmem_strfree(recvdstr);
if (isint) { if (isint) {
VERIFY0(dsl_prop_get_int_ds(ds, propname, &intval)); VERIFY0(dsl_prop_get_int_ds(ds, propname, &intval));
@ -1020,7 +1020,7 @@ dsl_prop_get_all_impl(objset_t *mos, uint64_t propobj,
valstr = kmem_asprintf("%s%s", propname, valstr = kmem_asprintf("%s%s", propname,
ZPROP_INHERIT_SUFFIX); ZPROP_INHERIT_SUFFIX);
err = zap_contains(mos, propobj, valstr); err = zap_contains(mos, propobj, valstr);
strfree(valstr); kmem_strfree(valstr);
if (err == 0) if (err == 0)
continue; continue;
if (err != ENOENT) if (err != ENOENT)

View File

@ -406,7 +406,7 @@ dsl_dataset_user_release_check_one(dsl_dataset_user_release_arg_t *ddura,
snapname, holdname); snapname, holdname);
fnvlist_add_int32(ddura->ddura_errlist, errtag, fnvlist_add_int32(ddura->ddura_errlist, errtag,
ENOENT); ENOENT);
strfree(errtag); kmem_strfree(errtag);
} }
continue; continue;
} }

View File

@ -533,7 +533,7 @@ log_internal(nvlist_t *nvl, const char *operation, spa_t *spa,
msg = kmem_vasprintf(fmt, adx); msg = kmem_vasprintf(fmt, adx);
fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg); fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg);
strfree(msg); kmem_strfree(msg);
fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation); fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation);
fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg); fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg);

View File

@ -431,9 +431,9 @@ get_special_prop(lua_State *state, dsl_dataset_t *ds, const char *dsname,
if (strcmp(strval, "") == 0) if (strcmp(strval, "") == 0)
error = ENOENT; error = ENOENT;
strfree(childval); kmem_strfree(childval);
} }
strfree(token); kmem_strfree(token);
break; break;
} }
case ZFS_PROP_VOLSIZE: case ZFS_PROP_VOLSIZE:
@ -661,7 +661,7 @@ get_userquota_prop(const char *prop_name)
* prop type as well as the numeric group/user ids based on the string * prop type as well as the numeric group/user ids based on the string
* following the '@' in the property name. On success, returns 0. On failure, * following the '@' in the property name. On success, returns 0. On failure,
* returns a non-zero error. * returns a non-zero error.
* 'domain' must be free'd by caller using strfree() * 'domain' must be free'd by caller using kmem_strfree()
*/ */
static int static int
parse_userquota_prop(const char *prop_name, zfs_userquota_prop_t *type, parse_userquota_prop(const char *prop_name, zfs_userquota_prop_t *type,
@ -688,7 +688,7 @@ parse_userquota_prop(const char *prop_name, zfs_userquota_prop_t *type,
(void) ddi_strtoll(cp, &end, 10, (longlong_t *)rid); (void) ddi_strtoll(cp, &end, 10, (longlong_t *)rid);
if (*end != '\0') { if (*end != '\0') {
strfree(domain_val); kmem_strfree(domain_val);
return (EINVAL); return (EINVAL);
} }
} else { } else {
@ -736,7 +736,7 @@ zcp_get_userquota_prop(lua_State *state, dsl_pool_t *dp,
} }
} }
if (domain != NULL) if (domain != NULL)
strfree(domain); kmem_strfree(domain);
} }
dsl_dataset_rele(ds, FTAG); dsl_dataset_rele(ds, FTAG);

View File

@ -3493,7 +3493,7 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
return (SET_ERROR(EINVAL)); return (SET_ERROR(EINVAL));
(void) tsd_set(zfs_allow_log_key, NULL); (void) tsd_set(zfs_allow_log_key, NULL);
error = spa_open(poolname, &spa, FTAG); error = spa_open(poolname, &spa, FTAG);
strfree(poolname); kmem_strfree(poolname);
if (error != 0) if (error != 0)
return (error); return (error);
@ -4152,7 +4152,7 @@ recursive_unmount(const char *fsname, void *arg)
fullname = kmem_asprintf("%s@%s", fsname, snapname); fullname = kmem_asprintf("%s@%s", fsname, snapname);
zfs_unmount_snap(fullname); zfs_unmount_snap(fullname);
strfree(fullname); kmem_strfree(fullname);
return (0); return (0);
} }
@ -4688,7 +4688,7 @@ zfs_allow_log_destroy(void *arg)
char *poolname = arg; char *poolname = arg;
if (poolname != NULL) if (poolname != NULL)
strfree(poolname); kmem_strfree(poolname);
} }
#ifdef DEBUG #ifdef DEBUG
@ -5907,8 +5907,8 @@ zfs_ioc_tmp_snapshot(zfs_cmd_t *zc)
if (error == 0) if (error == 0)
(void) strlcpy(zc->zc_value, snap_name, (void) strlcpy(zc->zc_value, snap_name,
sizeof (zc->zc_value)); sizeof (zc->zc_value));
strfree(snap_name); kmem_strfree(snap_name);
strfree(hold_name); kmem_strfree(hold_name);
zfs_onexit_fd_rele(zc->zc_cleanup_fd); zfs_onexit_fd_rele(zc->zc_cleanup_fd);
return (error); return (error);
} }
@ -7335,7 +7335,7 @@ zfsdev_ioctl_common(uint_t vecnum, unsigned long arg)
goto out; goto out;
/* legacy ioctls can modify zc_name */ /* legacy ioctls can modify zc_name */
saved_poolname = strdup(zc->zc_name); saved_poolname = kmem_strdup(zc->zc_name);
if (saved_poolname == NULL) { if (saved_poolname == NULL) {
error = SET_ERROR(ENOMEM); error = SET_ERROR(ENOMEM);
goto out; goto out;
@ -7420,11 +7420,11 @@ out:
if (error == 0 && vec->zvec_allow_log) { if (error == 0 && vec->zvec_allow_log) {
char *s = tsd_get(zfs_allow_log_key); char *s = tsd_get(zfs_allow_log_key);
if (s != NULL) if (s != NULL)
strfree(s); kmem_strfree(s);
(void) tsd_set(zfs_allow_log_key, saved_poolname); (void) tsd_set(zfs_allow_log_key, saved_poolname);
} else { } else {
if (saved_poolname != NULL) if (saved_poolname != NULL)
strfree(saved_poolname); kmem_strfree(saved_poolname);
} }
kmem_free(zc, sizeof (zfs_cmd_t)); kmem_free(zc, sizeof (zfs_cmd_t));

View File

@ -1009,7 +1009,7 @@ zvol_create_snap_minor_cb(const char *dsname, void *arg)
"%s is not a snapshot name\n", dsname); "%s is not a snapshot name\n", dsname);
} else { } else {
minors_job_t *job; minors_job_t *job;
char *n = strdup(dsname); char *n = kmem_strdup(dsname);
if (n == NULL) if (n == NULL)
return (0); return (0);
@ -1051,7 +1051,7 @@ zvol_create_minors_cb(const char *dsname, void *arg)
*/ */
if (strchr(dsname, '@') == 0) { if (strchr(dsname, '@') == 0) {
minors_job_t *job; minors_job_t *job;
char *n = strdup(dsname); char *n = kmem_strdup(dsname);
if (n == NULL) if (n == NULL)
return (0); return (0);
@ -1152,7 +1152,7 @@ zvol_create_minors_impl(const char *name)
list_remove(&minors_list, job); list_remove(&minors_list, job);
if (!job->error) if (!job->error)
ops->zv_create_minor(job->name); ops->zv_create_minor(job->name);
strfree(job->name); kmem_strfree(job->name);
kmem_free(job, sizeof (minors_job_t)); kmem_free(job, sizeof (minors_job_t));
} }
@ -1305,7 +1305,7 @@ zvol_rename_minors_impl(const char *oldname, const char *newname)
zv->zv_name[oldnamelen], zv->zv_name[oldnamelen],
zv->zv_name + oldnamelen + 1); zv->zv_name + oldnamelen + 1);
ops->zv_rename_minor(zv, name); ops->zv_rename_minor(zv, name);
strfree(name); kmem_strfree(name);
} }
mutex_exit(&zv->zv_state_lock); mutex_exit(&zv->zv_state_lock);