summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2022-10-13 05:39:11 +0000
committerOle Tr�an <otroan@employees.org>2022-10-17 05:43:14 +0000
commit80c0ae24378f249b3be9a02774d844c13143cd99 (patch)
treec812e04785c8b6c04903c45e0548e0b538a79e99 /src
parent368dab36991a875a62b01bbd66940b419146a911 (diff)
vlib: Counter free needs to NULL the allocated counter vector
otherwise the next time the counter is validated this is dangling. Type: fix Fixes: 58fd481d73 Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: Ifa8d5ff27175cf6dfb30cbf023fa3251fe5c780e
Diffstat (limited to 'src')
-rw-r--r--src/plugins/unittest/counter_test.c6
-rw-r--r--src/vlib/counter.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/unittest/counter_test.c b/src/plugins/unittest/counter_test.c
index 65c03fe89f1..71f8f93f94d 100644
--- a/src/plugins/unittest/counter_test.c
+++ b/src/plugins/unittest/counter_test.c
@@ -89,6 +89,9 @@ test_simple_counter_expand (vlib_main_t *vm)
epoch = new_epoch;
}
+ vlib_free_simple_counter (&counter);
+ vlib_validate_simple_counter (&counter, 0);
+
return 0;
}
@@ -136,6 +139,9 @@ test_combined_counter_expand (vlib_main_t *vm)
epoch = new_epoch;
}
+ vlib_free_combined_counter (&counter);
+ vlib_validate_combined_counter (&counter, 0);
+
return 0;
}
diff --git a/src/vlib/counter.c b/src/vlib/counter.c
index 4f375dee938..9f14d02909f 100644
--- a/src/vlib/counter.c
+++ b/src/vlib/counter.c
@@ -108,7 +108,10 @@ vlib_free_simple_counter (vlib_simple_counter_main_t * cm)
vec_free (cm->counters);
}
else
- vlib_stats_remove_entry (cm->stats_entry_index);
+ {
+ vlib_stats_remove_entry (cm->stats_entry_index);
+ cm->counters = NULL;
+ }
}
void
@@ -176,7 +179,10 @@ vlib_free_combined_counter (vlib_combined_counter_main_t * cm)
vec_free (cm->counters);
}
else
- vlib_stats_remove_entry (cm->stats_entry_index);
+ {
+ vlib_stats_remove_entry (cm->stats_entry_index);
+ cm->counters = NULL;
+ }
}
u32