diff options
author | Brian Behlendorf <[email protected]> | 2013-10-02 10:00:04 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-10-09 09:16:36 -0700 |
commit | 222b94805903dfa6879565ab9b1c8e3b0d70cbdf (patch) | |
tree | d9b87e9717007073c3d9e3c8fb744345bf63b8dd /module/zfs/spa_history.c | |
parent | 3549721c9e1f737fb7ba83d1fd52f396fd16889c (diff) |
Fix memory leak false positive in log_internal()
When building the spl with --enable-debug-kmem-tracking a memory
leak is detected in log_internal(). This happens to be a false
positive because the memory was freed using strfree() instead of
kmem_free(). All kmem_alloc()'s must be released with kmem_free()
to ensure correct accounting.
SPL: kmem leaked 135/5641311 bytes
address size data func:line
ffff8800cba7cd80 135 ZZZZZZZZZZZZZZZZ log_internal:456
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs/spa_history.c')
-rw-r--r-- | module/zfs/spa_history.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/module/zfs/spa_history.c b/module/zfs/spa_history.c index bbcd697e0..cb4816715 100644 --- a/module/zfs/spa_history.c +++ b/module/zfs/spa_history.c @@ -441,6 +441,7 @@ log_internal(nvlist_t *nvl, const char *operation, spa_t *spa, { char *msg; va_list adx1; + int size; /* * If this is part of creating a pool, not everything is @@ -453,13 +454,14 @@ log_internal(nvlist_t *nvl, const char *operation, spa_t *spa, } va_copy(adx1, adx); - msg = kmem_alloc(vsnprintf(NULL, 0, fmt, adx1) + 1, KM_PUSHPAGE); + size = vsnprintf(NULL, 0, fmt, adx1) + 1; + msg = kmem_alloc(size, KM_PUSHPAGE); va_end(adx1); va_copy(adx1, adx); (void) vsprintf(msg, fmt, adx1); va_end(adx1); fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg); - strfree(msg); + kmem_free(msg, size); fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation); fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg); |