Reviewed-by: Robbie King <[email protected]>

-----Original Message-----
From: lng-odp [mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Wednesday, April 08, 2015 2:28 AM
To: [email protected]
Subject: [lng-odp] [PATCH 1/1 v1] examples: odp_ipsec: handle alloc_pkt_ctx 
failure

From: Alexandru Badicioiu <[email protected]>

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

Signed-off-by: Alexandru Badicioiu <[email protected]>
---
 example/ipsec/odp_ipsec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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)) {
-- 
2.3.4.263.gf53fc38

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to