Skip to content

Commit

Permalink
ethdev: check info query return
Browse files Browse the repository at this point in the history
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@networkplumber.org>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
  • Loading branch information
shemminger authored and tmonjalo committed Nov 11, 2024
1 parent 6c5e32c commit 69559d0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ethdev/rte_class_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 69559d0

Please sign in to comment.