Reviewed-by: John Daley [email protected]<mailto:[email protected]>

From: Chengwen Feng <[email protected]>
Date: Monday, March 20, 2023 at 2:28 AM
To: [email protected] <[email protected]>, [email protected] 
<[email protected]>, John Daley (johndale) <[email protected]>, Hyong Youb 
Kim (hyonkim) <[email protected]>
Cc: [email protected] <[email protected]>
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: [email protected]

Signed-off-by: Chengwen Feng <[email protected]>
---
 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

Reply via email to