diff options
author | Steven Luong <sluong@cisco.com> | 2020-07-17 09:09:16 -0700 |
---|---|---|
committer | steven luong <sluong@cisco.com> | 2020-07-21 14:18:55 +0000 |
commit | 7364e2195cb91050cb608c1b423305587984e2c0 (patch) | |
tree | a98539b27b61e0d62322e87db30495a6e67d3ced /src | |
parent | 64b6dd7f8f120251e10ee84ff491beb6bae36e82 (diff) |
stats: memory leak in stat_validate_counter_vector
Free the existing vectors prior to losing them.
Type: fix
Ticket: VPPSUPP-94
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: Ic15f1fbc7a0c6c348065fc9759ee5d5c43013b91
Signed-off-by: Ole Troan <ot@cisco.com>
(cherry picked from commit e29fb5bf1b9ab87f4213d990377ea2604990135b)
Diffstat (limited to 'src')
-rw-r--r-- | src/vpp/stats/stat_segment.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c index f48b2d05062..8eeb38387d7 100644 --- a/src/vpp/stats/stat_segment.c +++ b/src/vpp/stats/stat_segment.c @@ -199,20 +199,28 @@ stat_validate_counter_vector (stat_segment_directory_entry_t * ep, u32 max) { stat_segment_main_t *sm = &stat_segment_main; stat_segment_shared_header_t *shared_header = sm->shared_header; - counter_t **counters = 0; + counter_t **counters = + ep->offset ? stat_segment_pointer (shared_header, ep->offset) : 0; vlib_thread_main_t *tm = vlib_get_thread_main (); int i; u64 *offset_vector = 0; vec_validate_aligned (counters, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); + ep->offset = stat_segment_offset (shared_header, counters); + for (i = 0; i < tm->n_vlib_mains; i++) { vec_validate_aligned (counters[i], max, CLIB_CACHE_LINE_BYTES); vec_add1 (offset_vector, stat_segment_offset (shared_header, counters[i])); } - ep->offset = stat_segment_offset (shared_header, counters); + + if (ep->offset_vector) + { + u64 *p = stat_segment_pointer (sm->shared_header, ep->offset_vector); + vec_free (p); + } ep->offset_vector = stat_segment_offset (shared_header, offset_vector); } |