[PATCH 09/10] ethdev: check return value from rte_eth_dev_info_get
Stephen Hemminger
stephen at networkplumber.org
Fri Oct 4 18:21:56 CEST 2024
The mac compare must check return value from rte_eth_dev_info_get
before using the dev_info information.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/ethdev/rte_class_eth.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c
index b52f1dd9f2..43e13e02f8 100644
--- a/lib/ethdev/rte_class_eth.c
+++ b/lib/ethdev/rte_class_eth.c
@@ -50,8 +50,10 @@ eth_mac_cmp(const char *key __rte_unused,
if (rte_ether_unformat_addr(value, &mac) < 0)
return -1; /* invalid devargs value */
+ if (rte_eth_dev_info_get(data->port_id, &dev_info) != 0)
+ return -1; /* device mac address unavailable */
+
/* Return 0 if devargs MAC is matching one of the device MACs. */
- rte_eth_dev_info_get(data->port_id, &dev_info);
for (index = 0; index < dev_info.max_mac_addrs; index++)
if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index]))
return 0;
--
2.45.2
More information about the dev
mailing list