[8/9] dma/skeleton: fix segment fault when parse devargs
Checks
Commit Message
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: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/skeleton/skeleton_dmadev.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -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;
}