summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-27 22:41:39 +0000
committerDave Barach <openvpp@barachs.net>2020-04-28 00:56:19 +0000
commit5226d26d1191fec2cb2bf1d896aa1f7ae1114cc4 (patch)
tree666e49a1e293104c28ace7921560d554d57ade1e
parent3ff8e23d7d44b5394112e3558206a7165642116a (diff)
svm: null instead of panic if fifo hdr alloc fails
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I2c5c9e3e7eff8481e48a940e8420d236a16e7649
-rw-r--r--src/svm/fifo_segment.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 06b7f063136..d9ca3a2afe3 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -420,8 +420,11 @@ fs_try_alloc_fifo_freelist_multi_chunk (fifo_segment_header_t * fsh,
f = fss->free_fifos;
if (!f)
{
+ if (PREDICT_FALSE (fsh_n_free_bytes (fsh) < sizeof (svm_fifo_t)))
+ return 0;
+
void *oldheap = ssvm_push_heap (fsh->ssvm_sh);
- f = clib_mem_alloc_aligned (sizeof (*f), CLIB_CACHE_LINE_BYTES);
+ f = clib_mem_alloc_aligned_or_null (sizeof (*f), CLIB_CACHE_LINE_BYTES);
ssvm_pop_heap (oldheap);
if (!f)
return 0;