[PATCH v2 13/44] net/enic: fix segment fault when parse devargs

John Daley (johndale) johndale at cisco.com
Mon Mar 20 22:37:25 CET 2023


    Reviewed-by: John Daley johndale at cisco.com<mailto:johndale at cisco.com>

From: Chengwen Feng <fengchengwen at huawei.com>
Date: Monday, March 20, 2023 at 2:28 AM
To: thomas at monjalon.net <thomas at monjalon.net>, ferruh.yigit at amd.com <ferruh.yigit at amd.com>, John Daley (johndale) <johndale at cisco.com>, Hyong Youb Kim (hyonkim) <hyonkim at cisco.com>
Cc: dev at dpdk.org <dev at dpdk.org>
Subject: [PATCH v2 13/44] net/enic: fix segment fault when parse devargs
The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.

This patch fixes segment fault when parse input args with 'only keys'.

Fixes: 93fb21fdbe23 ("net/enic: enable overlay offload for VXLAN and GENEVE")
Fixes: e39c2756e21a ("net/enic: add devarg to specify ingress VLAN rewrite mode")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 drivers/net/enic/enic_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index cdf0915591..b67016e0a3 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1148,6 +1148,9 @@ static int enic_parse_zero_one(const char *key,
         struct enic *enic;
         bool b;

+       if (value == NULL)
+               return -EINVAL;
+
         enic = (struct enic *)opaque;
         if (strcmp(value, "0") == 0) {
                 b = false;
@@ -1173,6 +1176,9 @@ static int enic_parse_ig_vlan_rewrite(__rte_unused const char *key,
 {
         struct enic *enic;

+       if (value == NULL)
+               return -EINVAL;
+
         enic = (struct enic *)opaque;
         if (strcmp(value, "trunk") == 0) {
                 /* Trunk mode: always tag */
--
2.17.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mails.dpdk.org/archives/dev/attachments/20230320/ab165723/attachment.htm>


More information about the dev mailing list