HomeFreeBSD

Fix zfsdev_ioctl() kmem leak warning

Description

Fix zfsdev_ioctl() kmem leak warning

Due to an asymmetry in the kmem accounting a memory leak was being
reported when it was only an accounting issue. All memory allocated
with kmem_alloc() must be released with kmem_free() or it will not
be properly accounted for.

In this case the code used strfree() to release the memory allocated
by kmem_alloc(). Presumably this was done because the size of the
memory region wasn't available when the memory needed to be freed.

To resolve this issue the code has been updated to use strdup() instead
of kmem_alloc() to allocate the memory. Like strfree(), strdup() is
not integrated with the memory accounting. This means we can use
strfree() to release it like Illumos.

SPL: kmem leaked 10/4368729 bytes
address          size  data             func:line
ffff880067e9aa40 10    ZZZZZZZZZZ       zfsdev_ioctl:5655

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #2262

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Apr 17 2014, 5:06 PM
Parents
rGe0b8f6290216: Various zimport.sh fixes
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG4fd762f8ad59: Fix zfsdev_ioctl() kmem leak warning (authored by Brian Behlendorf <behlendorf1@llnl.gov>).Apr 18 2014, 8:30 PM