diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index e50db3b05883..58c9d4bdf848 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -1929,7 +1929,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp, int *ncookies, u_lon uio->uio_loffset = offset; ZFS_EXIT(zfsvfs); - if (error != 0) { + if (error != 0 && *cookies != NULL) { free(*cookies, M_TEMP); *cookies = NULL; *ncookies = 0; diff --git a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index e50db3b05883..58c9d4bdf848 100644 --- a/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -1929,7 +1929,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp, int *ncookies, u_lon uio->uio_loffset = offset; ZFS_EXIT(zfsvfs); - if (error != 0) { + if (error != 0 && *cookies != NULL) { free(*cookies, M_TEMP); *cookies = NULL; *ncookies = 0;