[PATCH 5/9] cryptodev: fix null name when parse input args
Chengwen Feng
fengchengwen at huawei.com
Thu Mar 2 08:50:08 CET 2023
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'.
If the input args is just "name" (which mean only has keys), then it
will get (null) name in rte_cryptodev_pmd_parse_name_arg(). This patch
fixes it.
Fixes: 9e6edea41805 ("cryptodev: add APIs to assist PMD initialisation")
Cc: stable at dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
lib/cryptodev/cryptodev_pmd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 4122000839..d8073a601d 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -22,6 +22,9 @@ rte_cryptodev_pmd_parse_name_arg(const char *key __rte_unused,
struct rte_cryptodev_pmd_init_params *params = extra_args;
int n;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
n = strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
if (n >= RTE_CRYPTODEV_NAME_MAX_LEN)
return -EINVAL;
--
2.17.1
More information about the dev
mailing list