Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
Commit Message
fengchengwen
March 20, 2023, 9:20 a.m. UTC
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 args with 'only keys'
(e.g. 'mac,representor').
Fixes: c10cdce180a6 ("ethdev: support MAC address as iterator filter")
Fixes: a7d3c6271d55 ("ethdev: support representor id as iterator filter")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/ethdev/rte_class_eth.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On 3/20/23 12:20, Chengwen Feng wrote: > 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 args with 'only keys' > (e.g. 'mac,representor'). > > Fixes: c10cdce180a6 ("ethdev: support MAC address as iterator filter") > Fixes: a7d3c6271d55 ("ethdev: support representor id as iterator filter") > Cc: stable@dpdk.org > > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c index b61dae849d..b9fc25348b 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -46,6 +46,9 @@ eth_mac_cmp(const char *key __rte_unused, struct rte_eth_dev_info dev_info; uint32_t index; + if (value == NULL) + return -EINVAL; + /* Parse devargs MAC address. */ if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ @@ -72,6 +75,9 @@ eth_representor_cmp(const char *key __rte_unused, if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) return -1; /* not a representor port */ + if (value == NULL) + return -EINVAL; + /* Parse devargs representor values. */ values = strdup(value); if (values == NULL)