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: 25b05a1c806b ("crypto/mvsam: parse max number of sessions")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
 drivers/crypto/mvsam/rte_mrvl_pmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c 
b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 1641da9ca6..8f99197beb 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -1126,6 +1126,9 @@ parse_integer_arg(const char *key __rte_unused,
 {
        int *i = (int *) extra_args;
 
+       if (value == NULL)
+               return -EINVAL;
+
        *i = atoi(value);
        if (*i < 0) {
                MRVL_LOG(ERR, "Argument has to be positive!");
@@ -1142,6 +1145,9 @@ parse_name_arg(const char *key __rte_unused,
 {
        struct rte_cryptodev_pmd_init_params *params = extra_args;
 
+       if (value == NULL)
+               return -EINVAL;
+
        if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) {
                MRVL_LOG(ERR, "Invalid name %s, should be less than %u bytes!",
                         value, RTE_CRYPTODEV_NAME_MAX_LEN - 1);
-- 
2.17.1

Reply via email to