diff mbox

[1/1] odp_ipsec: handle alloc_pkt_ctx failure

Message ID 1427881005-1484-1-git-send-email-alexandru.badicioiu@linaro.org
State Accepted
Commit fc29357a5b390a9eed10111cdc8c5f21ff07c163
Headers show

Commit Message

Alexandru Badicioiu April 1, 2015, 9:36 a.m. UTC
From: Alexandru Badicioiu <alexandru.badicioiu@linaro.org>

Application should continue in case a packet context cannot be
allocated.

Signed-off-by: Alexandru Badicioiu <alexandru.badicioiu@linaro.org>
---
 example/ipsec/odp_ipsec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 56e9aa8..0cbf5b4 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -187,9 +187,8 @@  pkt_ctx_t *alloc_pkt_ctx(odp_packet_t pkt)
 	odp_buffer_t ctx_buf = odp_buffer_alloc(ctx_pool);
 	pkt_ctx_t *ctx;
 
-	/* There should always be enough contexts */
 	if (odp_unlikely(ODP_BUFFER_INVALID == ctx_buf))
-		abort();
+		return NULL;
 
 	ctx = odp_buffer_addr(ctx_buf);
 	memset(ctx, 0, sizeof(*ctx));
@@ -1017,6 +1016,10 @@  void *pktio_thread(void *arg EXAMPLE_UNUSED)
 				ctx = get_pkt_ctx_from_pkt(pkt);
 			} else {
 				ctx = alloc_pkt_ctx(pkt);
+				if (!ctx) {
+					odp_packet_free(pkt);
+					continue;
+				}
 				ctx->state = PKT_STATE_INPUT_VERIFY;
 			}
 		} else if (ODP_EVENT_CRYPTO_COMPL == odp_event_type(ev)) {