patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] examples/ioat: fix unchecked return value
@ 2020-02-04 16:01 Ciara Power
  2020-02-07 10:24 ` [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check Ciara Power
  0 siblings, 1 reply; 5+ messages in thread
From: Ciara Power @ 2020-02-04 16:01 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ciara Power, pawelx.modrak, stable

The return value of the get link function call was not checked, and
could return a negative value indicating a failure. If the return value
is not 0 for success, the loop continues with the next port.

To avoid a slight name clash with the new ret variable, the existing
retval variable is renamed to link_status, to better represent its use.

Coverity issue: 350348
Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
Cc: pawelx.modrak@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 examples/ioat/ioatfwd.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index e9117718f..99ecc0fde 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -697,7 +697,7 @@ check_link_status(uint32_t port_mask)
 {
 	uint16_t portid;
 	struct rte_eth_link link;
-	int retval = 0;
+	int ret, link_status = 0;
 
 	printf("\nChecking link status\n");
 	RTE_ETH_FOREACH_DEV(portid) {
@@ -705,7 +705,12 @@ check_link_status(uint32_t port_mask)
 			continue;
 
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get(portid, &link);
+		ret = rte_eth_link_get(portid, &link);
+		if (ret < 0) {
+			printf("Port %u link get failed: err=%d\n",
+					portid, ret);
+			continue;
+		}
 
 		/* Print link status */
 		if (link.link_status) {
@@ -714,11 +719,11 @@ check_link_status(uint32_t port_mask)
 				portid, link.link_speed,
 				(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
 				("full-duplex") : ("half-duplex\n"));
-			retval = 1;
+			link_status = 1;
 		} else
 			printf("Port %d Link Down\n", portid);
 	}
-	return retval;
+	return link_status;
 }
 
 static void
-- 
2.17.1


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

* [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-04 16:01 [dpdk-stable] [PATCH] examples/ioat: fix unchecked return value Ciara Power
@ 2020-02-07 10:24 ` Ciara Power
  2020-02-13 12:10   ` Bruce Richardson
  2020-02-13 14:01   ` [dpdk-stable] [dpdk-dev] " David Marchand
  0 siblings, 2 replies; 5+ messages in thread
From: Ciara Power @ 2020-02-07 10:24 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ciara Power, pawelx.modrak, stable

The return value of the get link function call was not checked, and
could return a negative value indicating a failure. This meant the
link_status of the link being checked is invalid, because the link was
not filled with data. The return value is now checked, and if the return
value is not 0 for success, the loop continues with the next port.

To avoid confusion between variable names, the existing retval variable
is renamed to link_status, to better represent its use.

Coverity issue: 350348
Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
Cc: pawelx.modrak@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>

---
v2:
  - Changed commit log subject and description
  - Rebased onto master
---
 examples/ioat/ioatfwd.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index e9117718f..99ecc0fde 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -697,7 +697,7 @@ check_link_status(uint32_t port_mask)
 {
 	uint16_t portid;
 	struct rte_eth_link link;
-	int retval = 0;
+	int ret, link_status = 0;
 
 	printf("\nChecking link status\n");
 	RTE_ETH_FOREACH_DEV(portid) {
@@ -705,7 +705,12 @@ check_link_status(uint32_t port_mask)
 			continue;
 
 		memset(&link, 0, sizeof(link));
-		rte_eth_link_get(portid, &link);
+		ret = rte_eth_link_get(portid, &link);
+		if (ret < 0) {
+			printf("Port %u link get failed: err=%d\n",
+					portid, ret);
+			continue;
+		}
 
 		/* Print link status */
 		if (link.link_status) {
@@ -714,11 +719,11 @@ check_link_status(uint32_t port_mask)
 				portid, link.link_speed,
 				(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
 				("full-duplex") : ("half-duplex\n"));
-			retval = 1;
+			link_status = 1;
 		} else
 			printf("Port %d Link Down\n", portid);
 	}
-	return retval;
+	return link_status;
 }
 
 static void
-- 
2.17.1


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

* Re: [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-07 10:24 ` [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check Ciara Power
@ 2020-02-13 12:10   ` Bruce Richardson
  2020-02-13 14:01   ` [dpdk-stable] [dpdk-dev] " David Marchand
  1 sibling, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2020-02-13 12:10 UTC (permalink / raw)
  To: Ciara Power; +Cc: dev, pawelx.modrak, stable

On Fri, Feb 07, 2020 at 10:24:02AM +0000, Ciara Power wrote:
> The return value of the get link function call was not checked, and
> could return a negative value indicating a failure. This meant the
> link_status of the link being checked is invalid, because the link was
> not filled with data. The return value is now checked, and if the return
> value is not 0 for success, the loop continues with the next port.
> 
> To avoid confusion between variable names, the existing retval variable
> is renamed to link_status, to better represent its use.
> 
> Coverity issue: 350348
> Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
> Cc: pawelx.modrak@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-07 10:24 ` [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check Ciara Power
  2020-02-13 12:10   ` Bruce Richardson
@ 2020-02-13 14:01   ` " David Marchand
  1 sibling, 0 replies; 5+ messages in thread
From: David Marchand @ 2020-02-13 14:01 UTC (permalink / raw)
  To: Ciara Power; +Cc: Bruce Richardson, dev, Pawel Modrak, dpdk stable

On Fri, Feb 7, 2020 at 11:34 AM Ciara Power <ciara.power@intel.com> wrote:
>
> The return value of the get link function call was not checked, and
> could return a negative value indicating a failure. This meant the
> link_status of the link being checked is invalid, because the link was
> not filled with data. The return value is now checked, and if the return
> value is not 0 for success, the loop continues with the next port.
>
> To avoid confusion between variable names, the existing retval variable
> is renamed to link_status, to better represent its use.
>
> Coverity issue: 350348
> Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.


--
David Marchand


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

* [dpdk-stable] [PATCH] examples/ioat: fix unchecked return value
@ 2020-02-04 16:03 Ciara Power
  0 siblings, 0 replies; 5+ messages in thread
From: Ciara Power @ 2020-02-04 16:03 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, Ciara Power, pawelx.modrak, stable

The function call to get the device info can return negative values on
failure, which was previously unchecked. This return value is now
checked and the function exits on failure.

Coverity issue: 350361
Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
Cc: pawelx.modrak@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 examples/ioat/ioatfwd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index e9117718f..029f2f0ab 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -824,7 +824,10 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)
 	/* Init port */
 	printf("Initializing port %u... ", portid);
 	fflush(stdout);
-	rte_eth_dev_info_get(portid, &dev_info);
+	ret = rte_eth_dev_info_get(portid, &dev_info);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE, "Error during getting device info:"
+			" err=%d, port=%u\n", ret, portid);
 	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
 		dev_info.flow_type_rss_offloads;
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
-- 
2.17.1


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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 16:01 [dpdk-stable] [PATCH] examples/ioat: fix unchecked return value Ciara Power
2020-02-07 10:24 ` [dpdk-stable] [PATCH v2] examples/ioat: fix invalid link status check Ciara Power
2020-02-13 12:10   ` Bruce Richardson
2020-02-13 14:01   ` [dpdk-stable] [dpdk-dev] " David Marchand
2020-02-04 16:03 [dpdk-stable] [PATCH] examples/ioat: fix unchecked return value Ciara Power

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox