[v2,40/44] event/octeontx: fix segment fault when parse devargs

Message ID 20230320092110.37295-41-fengchengwen@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series fix segment fault when parse args |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen March 20, 2023, 9:21 a.m. UTC
  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: 3516327e00fd ("event/octeontx: add selftest to device arguments")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/event/octeontx/ssovf_evdev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 650266b996..b9b5fa8668 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -717,6 +717,8 @@  static int
 ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque)
 {
 	int *flag = opaque;
+	if (value == NULL)
+		return -EINVAL;
 	*flag = !!atoi(value);
 	return 0;
 }