aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_bapi.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-07-01 07:32:31 -0700
committerDave Barach <openvpp@barachs.net>2019-07-02 11:52:49 +0000
commit617574dd4781cbeee3702aac70dd1137282da798 (patch)
tree5e646b3e1b8ff3f1bd11663738ed3bbae26d0fe5 /src/vcl/vcl_bapi.c
parentf4f73340d61e3af199291344e36a01d289f095f0 (diff)
vcl: handle fd rcv msg error
Type:fix Also cleanup worker fds on error. Reported by coverity Change-Id: I52cf77ca90e9ba1cc8ee9ddb3edaeabdc073beda Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vcl_bapi.c')
-rw-r--r--src/vcl/vcl_bapi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index 3ccac4740fc..7abb45b6330 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -113,8 +113,8 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
{
vcl_worker_t *wrk = vcl_worker_get (0);
u64 segment_handle;
+ int *fds = 0, i;
u32 n_fds = 0;
- int *fds = 0;
if (mp->retval)
{
@@ -134,7 +134,8 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
if (mp->n_fds)
{
vec_validate (fds, mp->n_fds);
- vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5);
+ if (vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5))
+ goto failed;
if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT)
if (vcl_segment_attach (vcl_vpp_worker_segment_handle (0),
@@ -169,13 +170,16 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
failed:
vcm->app_state = STATE_APP_FAILED;
+ for (i = clib_max (n_fds - 1, 0); i < vec_len (fds); i++)
+ close (fds[i]);
+ vec_free (fds);
}
static void
vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t *
mp)
{
- int n_fds = 0, *fds = 0;
+ int n_fds = 0, *fds = 0, i;
u64 segment_handle;
vcl_worker_t *wrk;
u32 wrk_index;
@@ -209,7 +213,8 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t *
if (mp->n_fds)
{
vec_validate (fds, mp->n_fds);
- vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5);
+ if (vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5))
+ goto failed;
if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT)
if (vcl_segment_attach (vcl_vpp_worker_segment_handle (wrk_index),
@@ -243,6 +248,9 @@ vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t *
failed:
vcm->app_state = STATE_APP_FAILED;
+ for (i = clib_max (n_fds - 1, 0); i < vec_len (fds); i++)
+ close (fds[i]);
+ vec_free (fds);
}
static void