aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-06-06 19:30:16 +0200
committerHongjun Ni <hongjun.ni@intel.com>2019-06-13 02:16:43 +0000
commitc7837f0e5956e751c43f909436a6365386ffb472 (patch)
treef3cc64e8f1ba213cb8fce17c9538eaeb82d6a2ad
parent024a13ac0d2e25dec620003e2538acb4598598fd (diff)
Correct a memory leak and an unused value
Change-Id: I40ca7b6017731b165c87a0653f40eb4d3cfaa22c Signed-off-by: YohanPipereau <ypiperea@cisco.com>
-rw-r--r--src/scvpp/inc/scvpp/comm.h5
-rw-r--r--src/scvpp/src/comm.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/scvpp/inc/scvpp/comm.h b/src/scvpp/inc/scvpp/comm.h
index da83fa7..ed02d5d 100644
--- a/src/scvpp/inc/scvpp/comm.h
+++ b/src/scvpp/inc/scvpp/comm.h
@@ -137,8 +137,11 @@ static inline int push(struct elt **stack, void *data, int length)
if (!el)
return -ENOMEM;
el->data = malloc(length);
- if (!el->data)
+ if (!el->data) {
+ free(el);
return -ENOMEM;
+ }
+
memcpy(el->data, data, length);
if (*stack)
diff --git a/src/scvpp/src/comm.c b/src/scvpp/src/comm.c
index 532ee1e..b679880 100644
--- a/src/scvpp/src/comm.c
+++ b/src/scvpp/src/comm.c
@@ -32,6 +32,10 @@ int sc_connect_vpp()
if (g_vapi_ctx == NULL)
{
vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx);
+ if (rv != VAPI_OK) {
+ g_vapi_ctx = NULL;
+ return -1;
+ }
rv = vapi_connect(g_vapi_ctx, APP_NAME, NULL,
MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE,
VAPI_MODE_BLOCKING, true);