block: fix leak of block histogram data
PATCH 1/1 block: fix leak of block histogram data
The block_acct_cleanup method failed to release memory associated with block histograms.
--- block/accounting.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/accounting.c +7 -0
@@ -80,6 +80,13 @@ bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,void block_acct_cleanup (BlockAcctStats *stats) {BlockAcctTimedStats *s, *next; +size_t i; +for (i =0 ; i <BLOCK_MAX_IOTYPE ; i++) { +BlockLatencyHistogram *hist = &stats->latency_histogram[i]; +g_free (hist->bins); +g_free (hist->boundaries); + } + QSLIST_FOREACH_SAFE(s, &stats->intervals, entries, next) {g_free (s); }
Signature · 1 line
2.56.0
Quoted 8 lines · Daniel P. Berrangé
The
block_acct_cleanupmethod failed to release memory associated with block histograms.Fixes b741ae7417 (block/accounting: introduce latency histogram)Signed-off-by Daniel P. Berrangé <[email protected]>--- block/accounting.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 23 lines
block/accounting.c +7
-0@@ -80,6 +80,13 @@ bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,void block_acct_cleanup (BlockAcctStats *stats) {BlockAcctTimedStats *s, *next; +size_t i; +for (i =0 ; i <BLOCK_MAX_IOTYPE ; i++) { +BlockLatencyHistogram *hist = &stats->latency_histogram[i]; +g_free (hist->bins); +g_free (hist->boundaries); + } + QSLIST_FOREACH_SAFE(s, &stats->intervals, entries, next) {g_free (s); }Signature · 1 line
2.56.0
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org
Am 12.10.2026 um 13:43 hat Daniel P. Berrangé geschrieben:
Quoted 14 lines
The
block_acct_cleanupmethod failed to release memory associated with block histograms.Fixes b741ae7417 (block/accounting: introduce latency histogram)Signed-off-by Daniel P. Berrangé <[email protected]>--- block/accounting.c | 7 +++++++ 1 file changed, 7 insertions(+)block/accounting.c +0
-0
block/accounting.c bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid, · line 89
Quoted 10 lines
block/accounting.c +7
-0@@ -80,6 +80,13 @@ bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,void block_acct_cleanup (BlockAcctStats *stats) {BlockAcctTimedStats *s, *next; +size_t i; +for (i =0 ; i <BLOCK_MAX_IOTYPE ; i++) { +BlockLatencyHistogram *hist = &stats->latency_histogram[i]; +g_free (hist->bins); +g_free (hist->boundaries); + } +
This seems to duplicate block_latency_histograms_clear(). Should we just call it here?
Kevin
Quoted 20 lines · Kevin Wolf
Am 12.10.2026 um 13:43 hat Daniel P. Berrangé geschrieben:
Quoted 19 lines
The
block_acct_cleanupmethod failed to release memory associated with block histograms.Fixes b741ae7417 (block/accounting: introduce latency histogram)Signed-off-by Daniel P. Berrangé <[email protected]>--- block/accounting.c | 7 +++++++ 1 file changed, 7 insertions(+)block/accounting.c +2
-0@@ -80,6 +80,13 @@ bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid,void block_acct_cleanup (BlockAcctStats *stats) {BlockAcctTimedStats *s, *next; +size_t i; +for (i =0 ; i <BLOCK_MAX_IOTYPE ; i++) {
Quoted 8 lines
block/accounting.c bool block_acct_setup(BlockAcctStats *stats, enum OnOffAuto account_invalid, · line 89
Quoted 5 lines
block/accounting.c +5
-0+BlockLatencyHistogram *hist = &stats->latency_histogram[i]; +g_free (hist->bins); +g_free (hist->boundaries); + } +This seems to duplicate
block_latency_histograms_clear(). Should we just call it here?
Yes, that sounds sensible, I'll repost.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|