mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
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:
parent
3549721c9e
commit
222b948059
@ -441,6 +441,7 @@ log_internal(nvlist_t *nvl, const char *operation, spa_t *spa,
|
|||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
va_list adx1;
|
va_list adx1;
|
||||||
|
int size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is part of creating a pool, not everything is
|
* 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);
|
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_end(adx1);
|
||||||
va_copy(adx1, adx);
|
va_copy(adx1, adx);
|
||||||
(void) vsprintf(msg, fmt, adx1);
|
(void) vsprintf(msg, fmt, adx1);
|
||||||
va_end(adx1);
|
va_end(adx1);
|
||||||
fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg);
|
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_string(nvl, ZPOOL_HIST_INT_NAME, operation);
|
||||||
fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg);
|
fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg);
|
||||||
|
Loading…
Reference in New Issue
Block a user