1 Star 0 Fork 76

chenjiji09/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0282-net-virtio-fix-empty-devargs-parsing.patch 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
chenjiji09 提交于 2023-04-27 15:25 . fix empty devargs parsing
From 51a50c25f5884df574cb254ee92de23bc821c0b4 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 2 Mar 2023 07:50:10 +0000
Subject: net/virtio: fix empty devargs parsing
[ upstream commit 1c1b35b59b4cee8836f34498b7c55b49de39d7b3 ]
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. vectorized,vdpa).
Fixes: 4710e16a4a7b ("net/virtio: add parameter to enable vectorized path")
Fixes: 44d7b2e87b69 ("net/virtio: refactor devargs parsing")
Fixes: 440f03c25378 ("net/virtio: skip device probe in vDPA mode")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/virtio/virtio_ethdev.c | 3 +++
drivers/net/virtio/virtio_pci_ethdev.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index a38b15d01c..c22b2f2889 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2474,6 +2474,9 @@ virtio_dev_speed_capa_get(uint32_t speed)
static int vectorized_check_handler(__rte_unused const char *key,
const char *value, void *ret_val)
{
+ if (value == NULL || ret_val == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1") == 0)
*(int *)ret_val = 1;
else
diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c
index 54645dc62e..de7b1ef344 100644
--- a/drivers/net/virtio/virtio_pci_ethdev.c
+++ b/drivers/net/virtio/virtio_pci_ethdev.c
@@ -138,6 +138,9 @@ eth_virtio_pci_uninit(struct rte_eth_dev *eth_dev)
static int vdpa_check_handler(__rte_unused const char *key,
const char *value, void *ret_val)
{
+ if (value == NULL || ret_val == NULL)
+ return -EINVAL;
+
if (strcmp(value, "1") == 0)
*(int *)ret_val = 1;
else
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenjiji09/dpdk.git
git@gitee.com:chenjiji09/dpdk.git
chenjiji09
dpdk
dpdk
master

搜索帮助