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));