Skip to content

Commit

Permalink
Fix zfs_allow_log_destroy() NULL dereference
Browse files Browse the repository at this point in the history
In zfs_ioc_log_history() function the tsd_set() function is called
with NULL which causes the zfs_allow_log_destroy() to be run.  In
this case the passed value will be NULL.  This is normally entirely
safe because strfree() maps directly to kfree() which may be passed
a NULL.  However, since alternate implementations of strfree() may
not handle this gracefully add a check for NULL.

Observed under an embedded Linux 2.6.32.41 kernel running the
automated testing while running the ZFS Test Suite.

Signed-off-by: caoxuewen <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #4872
  • Loading branch information
heary-cao authored and behlendorf committed Jul 29, 2016
1 parent 3b86aeb commit 9f3d140
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,8 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
* we clear the TSD here.
*/
poolname = tsd_get(zfs_allow_log_key);
if (poolname == NULL)
return (SET_ERROR(EINVAL));
(void) tsd_set(zfs_allow_log_key, NULL);
error = spa_open(poolname, &spa, FTAG);
strfree(poolname);
Expand Down Expand Up @@ -6297,7 +6299,9 @@ static void
zfs_allow_log_destroy(void *arg)
{
char *poolname = arg;
strfree(poolname);

if (poolname != NULL)
strfree(poolname);
}

#ifdef DEBUG
Expand Down

0 comments on commit 9f3d140

Please sign in to comment.