DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lpm: unchecked return value
@ 2016-04-27 12:52 Slawomir Mrozowicz
  2016-05-03 14:34 ` Bruce Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: Slawomir Mrozowicz @ 2016-04-27 12:52 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Slawomir Mrozowicz

Fix issue reported by Coverity.

Coverity ID 13205: Unchecked return value
Unchecked return value
check_return: Calling rte_lpm6_add without checking return value
Fixes: 5c510e13a9cb ("lpm: add IPv6 support")

Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com>
---
 lib/librte_lpm/rte_lpm6.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm6.c b/lib/librte_lpm/rte_lpm6.c
index ba4353c..f4db3fa 100644
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -749,6 +749,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth)
 	int32_t rule_to_delete_index;
 	uint8_t ip_masked[RTE_LPM6_IPV6_ADDR_SIZE];
 	unsigned i;
+	int status = 0;
 
 	/*
 	 * Check input arguments.
@@ -790,12 +791,13 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth)
 	 * Add every rule again (except for the one that was removed from
 	 * the rules table).
 	 */
-	for (i = 0; i < lpm->used_rules; i++) {
-		rte_lpm6_add(lpm, lpm->rules_tbl[i].ip, lpm->rules_tbl[i].depth,
-				lpm->rules_tbl[i].next_hop);
+	for (i = 0; i < lpm->used_rules && status >= 0; i++) {
+		status = rte_lpm6_add(
+			lpm, lpm->rules_tbl[i].ip, lpm->rules_tbl[i].depth,
+			lpm->rules_tbl[i].next_hop);
 	}
 
-	return 0;
+	return status;
 }
 
 /*
-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-23  9:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-27 12:52 [dpdk-dev] [PATCH] lpm: unchecked return value Slawomir Mrozowicz
2016-05-03 14:34 ` Bruce Richardson
2016-05-06 12:25   ` Mrozowicz, SlawomirX
2016-05-12 11:19     ` Azarewicz, PiotrX T
2016-06-23  8:13       ` Jastrzebski, MichalX K
2016-06-23  8:48         ` Bruce Richardson
2016-06-23  9:03           ` Jastrzebski, MichalX K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).