1 Star 0 Fork 75

chenjiji09/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0279-compressdev-fix-empty-devargs-parsing.patch 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
chenjiji09 提交于 2023-04-27 15:25 . fix empty devargs parsing
From 37b765efbca81e4aa81fcb685e7810398e800e29 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 2 Mar 2023 07:50:05 +0000
Subject: compressdev: fix empty devargs parsing
[ upstream commit bb27182482d61777de6a38b16a1d2c692c2c3f8b ]
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 in rte_compressdev_pmd_parse_uint_arg()
when parse input args with 'only keys' (e.g. socket_id).
For a similar reason, this patch fixes
rte_compressdev_pmd_parse_name_arg().
Fixes: ed7dd94f7f66 ("compressdev: add basic device management")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/compressdev/rte_compressdev_pmd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/compressdev/rte_compressdev_pmd.c b/lib/compressdev/rte_compressdev_pmd.c
index 7f500d76d4..6a11a396b7 100644
--- a/lib/compressdev/rte_compressdev_pmd.c
+++ b/lib/compressdev/rte_compressdev_pmd.c
@@ -20,6 +20,9 @@ rte_compressdev_pmd_parse_name_arg(const char *key __rte_unused,
struct rte_compressdev_pmd_init_params *params = extra_args;
int n;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
n = strlcpy(params->name, value, RTE_COMPRESSDEV_NAME_MAX_LEN);
if (n >= RTE_COMPRESSDEV_NAME_MAX_LEN)
return -EINVAL;
@@ -37,6 +40,9 @@ rte_compressdev_pmd_parse_uint_arg(const char *key __rte_unused,
int i;
char *end;
+ if (value == NULL || extra_args == NULL)
+ return -EINVAL;
+
errno = 0;
i = strtol(value, &end, 10);
if (*end != 0 || errno != 0 || i < 0)
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenjiji09/dpdk.git
git@gitee.com:chenjiji09/dpdk.git
chenjiji09
dpdk
dpdk
master

搜索帮助