From df32bc4dee0cfe514a8fca5085ea555211521387 Mon Sep 17 00:00:00 2001 From: Andrew Yourtchenko Date: Thu, 20 Sep 2018 15:36:51 +0200 Subject: bihash template: avoid memory leak upon rehash Call the BV (value_free) when we have performed the rehash and thus no longer need the memory that old value for the bucket refers to. Change-Id: Ibb82174fc8002aeb3e1a6c8d1f90293d73bc45d8 Signed-off-by: Andrew Yourtchenko --- src/vppinfra/bihash_template.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/vppinfra/bihash_template.c') diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index 2571c47e64c..752597ebbd5 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -627,6 +627,9 @@ expand_ok: tmp_b.lock = 0; CLIB_MEMORY_BARRIER (); b->as_u64 = tmp_b.as_u64; + /* free the old bucket */ + v = BV (clib_bihash_get_value) (h, h->saved_bucket.offset); + BV (value_free) (h, v, h->saved_bucket.log2_pages); BV (clib_bihash_alloc_unlock) (h); return (0); } -- cgit 1.2.3-korg