DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value
@ 2020-02-04 16:01 Ciara Power
  2020-02-07 10:24 ` [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status check Ciara Power
  0 siblings, 1 reply; 6+ 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] 6+ messages in thread

* [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-04 16:01 [dpdk-dev] [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   ` David Marchand
  0 siblings, 2 replies; 6+ 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] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-07 10:24 ` [dpdk-dev] [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; 6+ 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] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status check
  2020-02-07 10:24 ` [dpdk-dev] [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; 6+ 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] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value
  2020-02-04 16:03 [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value Ciara Power
@ 2020-02-05 10:58 ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2020-02-05 10:58 UTC (permalink / raw)
  To: Ciara Power; +Cc: Bruce Richardson, dev, Pawel Modrak, dpdk stable

On Tue, Feb 4, 2020 at 5:13 PM Ciara Power <ciara.power@intel.com> wrote:
>
> 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

We had the same patch proposed in 19.11 timeframe that got deferred to 20.02.
https://patchwork.dpdk.org/patch/63375/
Will mark https://patchwork.dpdk.org/patch/65563/ as rejected.


Besides, we have a patch with the exact same subject than this one.
https://patchwork.dpdk.org/patch/65562/

A title must (briefly) describe what functional impact the patch has.

-- 
David Marchand


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

* [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value
@ 2020-02-04 16:03 Ciara Power
  2020-02-05 10:58 ` David Marchand
  0 siblings, 1 reply; 6+ 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] 6+ messages in thread

end of thread, other threads:[~2020-02-13 14:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 16:01 [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value Ciara Power
2020-02-07 10:24 ` [dpdk-dev] [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
2020-02-04 16:03 [dpdk-dev] [PATCH] examples/ioat: fix unchecked return value Ciara Power
2020-02-05 10:58 ` David Marchand

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).