dpdk/0283-dma-skeleton-fix-empty-devargs-parsing.patch
chenjiji09 28f243f30b fix empty devargs parsing
Sync some patchs from upstreaming and modifies are as
follow:
1. The rte_kvargs_process() was used to parse KV pairs, it
also supports to parse 'only keys' 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'.
2. The MAP_FAILED should be used to determine whether the
mapping is successful but not NULL. This patch fix it.

(cherry picked from commit dfaed15bf9253e6b71dda7639806c0b265164a9e)
2023-04-29 07:48:24 +08:00

47 lines
1.3 KiB
Diff

From 9db4a191823cb2dec68c4be50bb1143c141da22c Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 2 Mar 2023 07:50:11 +0000
Subject: dma/skeleton: fix empty devargs parsing
[ upstream commit e0e5dd0450db22fc7712da4b5a8e6fd6e081c870 ]
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(-)
diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index 81cbdd286e..67e0357cf0 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -500,9 +500,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.23.0