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' (e.g. lcore). Fixes: 05d5fc66a269 ("dma/skeleton: introduce skeleton driver") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng <fengcheng...@huawei.com> --- drivers/dma/skeleton/skeleton_dmadev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 9b6da655fd..daf35eccce 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -515,9 +515,15 @@ skeldma_parse_lcore(const char *key __rte_unused, const char *value, void *opaque) { - int lcore_id = atoi(value); + int lcore_id; + + if (value == NULL || opaque == NULL) + return -EINVAL; + + lcore_id = atoi(value); if (lcore_id >= 0 && lcore_id < RTE_MAX_LCORE) *(int *)opaque = lcore_id; + return 0; } -- 2.17.1