From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hunt Subject: [PATCH v1] lib: fix coverity issues in distributor allocation Date: Tue, 4 Apr 2017 03:42:41 +0100 Message-ID: <1491273761-112722-1-git-send-email-david.hunt@intel.com> Cc: bruce.richardson@intel.com, david.hunt@intel.com To: dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id B87B0326C for ; Tue, 4 Apr 2017 11:41:59 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Coverity issue 143258: not freeing distributor instance Coverity issue 143254: not checking return code from malloc Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Signed-off-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 06df13d..4725904 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -621,9 +621,14 @@ rte_distributor_create_v1705(const char *name, if (alg_type == RTE_DIST_ALG_SINGLE) { d = malloc(sizeof(struct rte_distributor)); + if (d == NULL) { + rte_errno = ENOMEM; + return NULL; + } d->d_v20 = rte_distributor_create_v20(name, socket_id, num_workers); if (d->d_v20 == NULL) { + free(d); /* rte_errno will have been set */ return NULL; } -- 2.7.4