From 212f0bbac29eaf9618f4d867801f0d94a3668401 Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Sat, 1 Jun 2013 09:34:15 -0500 Subject: [PATCH] zfs_allow_log_key TSD key: re-work the handling of this key's value via saved_poolname. Build saved_poolname in a local array and then use strdup() to save it when necessary. The code previously allocated space for the TSD value with kmem_alloc which doesn't seemt to play well (accounting-wise) with strfree() (which is the function used to free the value later on). --- module/zfs/zfs_ioctl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d5200a2c8aff..0fc14d6c066c 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -5705,7 +5705,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg) uint_t vecnum; int error, rc, len, flag = 0; const zfs_ioc_vec_t *vec; - char *saved_poolname = NULL; + char saved_poolname[MAXNAMELEN]; nvlist_t *innvl = NULL; vecnum = cmd - ZFS_IOC_FIRST; @@ -5763,9 +5763,9 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg) goto out; /* legacy ioctls can modify zc_name */ - len = strcspn(zc->zc_name, "/@") + 1; - saved_poolname = kmem_alloc(len, KM_SLEEP); - (void) strlcpy(saved_poolname, zc->zc_name, len); + (void) strlcpy(saved_poolname, zc->zc_name, sizeof(saved_poolname)); + len = strcspn(saved_poolname, "/@") + 1; + saved_poolname[len] = '\0'; if (vec->zvec_func != NULL) { nvlist_t *outnvl; @@ -5830,10 +5830,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg) char *s = tsd_get(zfs_allow_log_key); if (s != NULL) strfree(s); - (void) tsd_set(zfs_allow_log_key, saved_poolname); - } else { - if (saved_poolname != NULL) - strfree(saved_poolname); + (void) tsd_set(zfs_allow_log_key, strdup(saved_poolname)); } kmem_free(zc, sizeof (zfs_cmd_t));