session: init lookup before dgram accept notification

Avoids potential session pointer invalidation

Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ide9ba0ab732707d3dda6019ebb77f0b9489dfda7
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 9429ddb..3a468b4 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1158,16 +1158,18 @@
       return rv;
     }
 
+  session_lookup_add_connection (tc, session_handle (s));
+
   app_wrk = app_worker_get (s->app_wrk_index);
   if ((rv = app_worker_accept_notify (app_wrk, s)))
     {
+      session_lookup_del_session (s);
       segment_manager_dealloc_fifos (s->rx_fifo, s->tx_fifo);
       session_free (s);
       return rv;
     }
 
   s->session_state = SESSION_STATE_READY;
-  session_lookup_add_connection (tc, session_handle (s));
 
   return 0;
 }