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 <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2013-10-02 10:00:04 -07:00
parent 3549721c9e
commit 222b948059

View File

@ -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);