Skip to content

Commit

Permalink
zfs_allow_log_key TSD key: re-work the handling of this key's value
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
dweeezil committed Jun 21, 2013
1 parent 43f9f51 commit 212f0bb
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 212f0bb

Please sign in to comment.