[7/9] net/virtio: 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. 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>
---
drivers/net/virtio/virtio_ethdev.c | 3 +++
drivers/net/virtio/virtio_pci_ethdev.c | 3 +++
2 files changed, 6 insertions(+)
@@ -2054,6 +2054,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
@@ -148,6 +148,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