[v4] app/testpmd: fix DCB set failure

Message ID 20200513100745.13118-1-ting.xu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v4] app/testpmd: fix DCB set failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Xu, Ting May 13, 2020, 10:07 a.m. UTC
  When set DCB in testpmd, there is a segmentation fault. It is
because the local variable rss_conf in get_eth_dcb_conf()
is not cleared, so that the pointer member variable rss_key has
a random address, which leads to an error in the following
processing. This patch initialized the local variable rss_conf
to avoid this situation.

Fixes: ac7c491c3fec ("app/testpmd: fix DCB config")
Cc: stable@dpdk.org

Signed-off-by: Ting Xu <ting.xu@intel.com>

---
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd
v1->v2: modify commit log, move memset to else leg
---
 lib/librte_ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Iremonger, Bernard May 13, 2020, 8:54 a.m. UTC | #1
Hi Ting,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ting Xu
> Sent: Wednesday, May 13, 2020 11:08 AM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; Yigit, Ferruh <ferruh.yigit@intel.com>;
> arybchenko@solarflare.com; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v4] app/testpmd: fix DCB set failure

The fix is no longer in testpmd, so the commit line should be "ethdev: fix DCB set failure".

 
> When set DCB in testpmd, there is a segmentation fault. It is because the
> local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the
> pointer member variable rss_key has a random address, which leads to an
> error in the following processing. This patch initialized the local variable
> rss_conf to avoid this situation.

The commit message should probably be revised.

> 
> Fixes: ac7c491c3fec ("app/testpmd: fix DCB config")

Also the Fixes line may need to change.

> Cc: stable@dpdk.org
> 
> Signed-off-by: Ting Xu <ting.xu@intel.com>
> 
> ---
> V3->v4: fix build failure
> v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd
> v1->v2: modify commit log, move memset to else leg
> ---
>  lib/librte_ethdev/rte_ethdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 8e10a6fc3..1f6ca742a 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -3549,6 +3549,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
> {
>  	struct rte_eth_dev *dev;
> 
> +	memset(rss_conf, 0, sizeof(*rss_conf));

The memset call should be moved to after the error checks to just before the function is called.

> +
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>  	dev = &rte_eth_devices[port_id];
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get,
> -ENOTSUP);
> --
> 2.17.1

Regards,

Bernard.
  
Thomas Monjalon May 13, 2020, 12:58 p.m. UTC | #2
13/05/2020 10:54, Iremonger, Bernard:
> The fix is no longer in testpmd, so the commit line should be "ethdev: fix DCB set failure".

In general, the word "failure" (or error, etc) is not needed.
Because it is a fix, we know there was a failure before :)

And specifically here, you are not fixing just DCB.
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..1f6ca742a 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3549,6 +3549,8 @@  rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 
+	memset(rss_conf, 0, sizeof(*rss_conf));
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);