aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm/fifo_segment.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-17 20:15:22 +0000
committerDave Barach <openvpp@barachs.net>2020-04-20 17:04:29 +0000
commit0e6199dfa20d4c010bf3ac43e051f9f29c213478 (patch)
tree9d5c471e1a7f7e5f0dd9b47bf52661a47a5d116f /src/svm/fifo_segment.c
parent7ce23f25bbc01d534ca294ce88ab0d709e3e03a7 (diff)
svm: check if fifo free list index is valid on alloc
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: BenoƮt Ganne <bganne@cisco.com> Change-Id: Ib85c2f01dc7ec9858f2f88b89e209f989d78c5d9
Diffstat (limited to 'src/svm/fifo_segment.c')
-rw-r--r--src/svm/fifo_segment.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index cfc795418b2..06b7f063136 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -615,6 +615,9 @@ fs_try_alloc_fifo (fifo_segment_header_t * fsh, fifo_segment_slice_t * fss,
min_size = clib_max ((fsh->pct_first_alloc * data_bytes) / 100, 4096);
fl_index = fs_freelist_for_size (min_size);
+ if (fl_index >= vec_len (fss->free_chunks))
+ return 0;
+
clib_spinlock_lock (&fss->chunk_lock);
if (fss->free_fifos && fss->free_chunks[fl_index])
@@ -691,6 +694,7 @@ fsh_alloc_chunk (fifo_segment_header_t * fsh, u32 slice_index, u32 chunk_size)
clib_spinlock_lock (&fss->chunk_lock);
+ ASSERT (vec_len (fss->free_chunks) > fl_index);
c = fss->free_chunks[fl_index];
if (c)
@@ -834,6 +838,9 @@ fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs, u32 slice_index,
ASSERT (slice_index < fs->n_slices);
+ if (PREDICT_FALSE (data_bytes > 1 << fsh->max_log2_chunk_size))
+ return 0;
+
fss = fsh_slice_get (fsh, slice_index);
f = fs_try_alloc_fifo (fsh, fss, data_bytes);
if (!f)