lb: keep AddressSanitizer happy 48/38048/2
authorBenoît Ganne <bganne@cisco.com>
Thu, 26 Jan 2023 15:04:43 +0000 (16:04 +0100)
committerDamjan Marion <dmarion@0xa5.net>
Mon, 6 Mar 2023 17:55:08 +0000 (17:55 +0000)
vec_alloc() does not mark vector as accessible contrary to
vec_validate().
Also removes redundant memset(0) as vector allocation always zeroed
new memory.

Type: fix

Change-Id: I8309831b964a618454ed0bebbcdec7ec21149414
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/lb/lb.c
src/plugins/lb/lbhash.h

index 7828334..c6f5a0a 100644 (file)
@@ -486,7 +486,7 @@ out:
   }
 
   //First, let's sort the ASs
-  vec_alloc(sort_arr, pool_elts(vip->as_indexes));
+  vec_validate (sort_arr, pool_elts (vip->as_indexes) - 1);
 
   i = 0;
   pool_foreach (as_index, vip->as_indexes) {
index f822d79..8253e9d 100644 (file)
@@ -88,8 +88,7 @@ lb_hash_t *lb_hash_alloc(u32 buckets, u32 timeout)
       sizeof(lb_hash_bucket_t) * (buckets + 1);
   u8 *mem = 0;
   lb_hash_t *h;
-  vec_alloc_aligned(mem, size, CLIB_CACHE_LINE_BYTES);
-  clib_memset(mem, 0, size);
+  vec_validate_aligned (mem, size - 1, CLIB_CACHE_LINE_BYTES);
   h = (lb_hash_t *)mem;
   h->buckets_mask = (buckets - 1);
   h->timeout = timeout;