Skip to contentSkip to conversation

examples/ip_pipeline: fix uninitialized scalar variable

PATCH Applied Fan Zhang 3 participants 4 messages Apr 16, 2018 – May 8, 2018

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 examples/ip_pipeline: fix uninitialized scalar variable

Coverity issue: 272575

Fixes 133c2c6565d6 ("examples/ip_pipeline: add link object")
---
 examples/ip_pipeline/cli.c  | 2 +-
 examples/ip_pipeline/link.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
examples/ip_pipeline/cli.c +1 -1
index 199a31ff8..ec43a2308 100644
@@ -133,7 +133,7 @@ cmd_link(char **tokens,
 	char *out,
 	size_t out_size)
 {
-	struct link_params p;
+	struct link_params p = {0};
 	struct link_params_rss rss;
 	struct link *link;
 	char *name;
examples/ip_pipeline/link.c +5 -3
index 26ff41ba9..25717808c 100644
@@ -121,17 +121,19 @@ link_create(const char *name, struct link_params *params)
 		(params->tx.queue_size == 0))
 		return NULL;
 
-	port_id = params->port_id;
 	if (params->dev_name) {
 		status = rte_eth_dev_get_port_by_name(params->dev_name,
 			&port_id);
 
 		if (status)
 			return NULL;
-	} else
-		if (!rte_eth_dev_is_valid_port(port_id))
+	} else {
+		if (!rte_eth_dev_is_valid_port(params->port_id))
 			return NULL;
 
+		port_id = params->port_id;
+	}
+
 	rte_eth_dev_info_get(port_id, &port_info);
 
 	mempool = mempool_find(params->rx.mempool_name);
Signature · 1 line
2.13.6
author
#1 lore raw

PATCH v2 1/1 examples/ip_pipeline: fix uninitialized scalar variable

Coverity issue: 272575

Fixes 133c2c6565d6 ("examples/ip_pipeline: add link object")

---
v2:
- removed unecessary link.c update

 examples/ip_pipeline/cli.c | 2 ++
 1 file changed, 2 insertions(+)
examples/ip_pipeline/cli.c +2 -0
index 199a31ff8..ec150ce4e 100644
@@ -138,6 +138,8 @@ cmd_link(char **tokens,
 	struct link *link;
 	char *name;
 
+	memset(&p, 0, sizeof(p));
+
 	if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
Signature · 1 line
2.13.6
Reviewed-by on v2 1/1
#2 lore raw
Quoted 35 lines

-----Original Message-----
From: Zhang, Roy Fan
Sent: Friday, April 20, 2018 3:39 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH v2] examples/ip_pipeline: fix uninitialized scalar variable

Coverity issue: 272575

Fixes 133c2c6565d6 ("examples/ip_pipeline: add link object")

---
v2:
- removed unecessary link.c update

 examples/ip_pipeline/cli.c | 2 ++
 1 file changed, 2 insertions(+)
examples/ip_pipeline/cli.c index renamed from examples/ip_pipeline/cli.c +0 -0

199a31ff8..ec150ce4e 100644

examples/ip_pipeline/cli.c +2 -1
@@ -138,6 +138,8 @@ cmd_link(char **tokens,
 	struct link *link;
 	char *name;
 
+	memset(&p, 0, sizeof(p));
+
 	if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
--
Quoted 1 line

2.13.6

Acked-by on v1 1/1 Applied
#3 lore raw
In reply to Fan Zhang
Quoted 10 lines

-----Original Message-----
From: Zhang, Roy Fan
Sent: Monday, April 16, 2018 11:48 AM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>; Singh, Jasvinder <[email protected]>
Subject: [PATCH] examples/ip_pipeline: fix uninitialized scalar variable

Quoted 6 lines

Coverity issue: 272575

Fixes 133c2c6565d6 ("examples/ip_pipeline: add link object")
---
 examples/ip_pipeline/cli.c  | 2 +-

Applied to next-pipeline tree, thanks!