Skip to contentSkip to conversation

lib: fix coverity issues in distributor allocation

PATCH In review David Hunt 2 participants 2 messages Apr 4, 2017

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 lib: fix coverity issues in distributor allocation

Coverity issue 143258: not freeing distributor instance Coverity issue 143254: not checking return code from malloc

Fixes 775003ad2f96 ("distributor: add new burst-capable library")
---
 lib/librte_distributor/rte_distributor.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_distributor/rte_distributor.c +5 -0
index 06df13d..4725904 100644
@@ -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;
 		}
Signature · 1 line
2.7.4
#1 lore raw

2017-04-04 03:42, David Hunt:

Quoted 6 lines

Coverity issue 143258: not freeing distributor instance Coverity issue 143254: not checking return code from malloc

Fixes 775003ad2f96 ("distributor: add new burst-capable library")

Applied with this title:
distributor: fix creation error checks
Thanks