aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-02-23 17:11:26 -0500
committerDave Barach <openvpp@barachs.net>2017-02-24 12:17:01 +0000
commit26cd8c129567b48ed0e3610293251ca78fa67103 (patch)
tree627830df91fa440ebbf4635a72848f80d1c85de9 /src/vlib
parent02767e9f2eaf7ccfc4079f83d467ad2d3faee203 (diff)
VPP-650: handle buffer failure in vlib_buffer_copy(...)
Change-Id: I6aac48d780fcd935818221044eae50067f225175 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer_funcs.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index fd051de53de..0b583a61994 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -489,7 +489,15 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
vec_validate (new_buffers, n_buffers - 1);
n_alloc = vlib_buffer_alloc (vm, new_buffers, n_buffers);
- ASSERT (n_alloc == n_buffers);
+
+ /* No guarantee that we'll get all the buffers we asked for */
+ if (PREDICT_FALSE (n_alloc < n_buffers))
+ {
+ if (n_alloc > 0)
+ vlib_buffer_free (vm, new_buffers, n_alloc);
+ vec_free (new_buffers);
+ return 0;
+ }
/* 1st segment */
s = b;
@@ -518,6 +526,7 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
d->flags = s->flags & flag_mask;
}
+ vec_free (new_buffers);
return fd;
}